You are given an array a_1, a_2, …, a_n.

You need to perform q queries of the following two types:

  1. "MULTIPLY l r x" — for every i (l ≤ i ≤ r) multiply a_i by x.
  2. "TOTIENT l r" — print \varphi(∏ _{i=l}^{r} a_i) taken modulo 10^9+7, where \varphi denotes Euler's totient function. 



The [Euler's totient function](http://gg.gg/euler_totient) of a positive integer n (denoted as \varphi(n)) is the number of integers x (1 ≤ x ≤ n) such that \gcd(n,x) = 1.

Input

The first line contains two integers n and q (1 ≤ n ≤ 4 ⋅ 10^5, 1 ≤ q ≤ 2 ⋅ 10^5) — the number of elements in array a and the number of queries.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300) — the elements of array a.

Then q lines follow, describing queries in the format given in the statement.

  1. "MULTIPLY l r x" (1 ≤ l ≤ r ≤ n, 1 ≤ x ≤ 300) — denotes a multiplication query.
  2. "TOTIENT l r" (1 ≤ l ≤ r ≤ n) — denotes a query on the value of Euler's totient function. 



It is guaranteed that there is at least one "TOTIENT" query.

Output

For each "TOTIENT" query, print the answer to it.

Example

Input

4 4
5 9 1 2
TOTIENT 3 3
TOTIENT 3 4
MULTIPLY 4 4 3
TOTIENT 4 4


Output

1
1
2

Note

In the first example, \varphi(1) = 1 for the first query, \varphi(2) = 1 for the second query and \varphi(6) = 2 for the third one.
#include <bits/stdc++.h>
using namespace std;
using namespace std;
template <class T, class U>
struct SegmentTree {
  struct Node {
    bool hasCarry = 0;
    int b = 0, e = 0;
    U carry = U();
    T val = T();
    Node() {}
    void join(const Node &l, const Node &r) {
      val = l.val + r.val;
      b = l.b;
      e = r.e;
    }
    void update(const U &u) {
      carry += u;
      u(val);
      hasCarry = 1;
    }
    void pushDown(Node &l, Node &r) {
      if (!hasCarry) return;
      l.update(carry.trim(0, r.e - r.b + 1));
      r.update(carry.trim(l.e - l.b + 1, 0));
      carry = U();
      hasCarry = 0;
    }
  };
  vector<Node> V;
  int N;
  SegmentTree(int N) : V(2 * N), N(N) {}
  template <class I>
  void create(const vector<I> &VEC, int b = 0, int e = -1) {
    if (e == -1) e = N - 1;
    int n = (((b) + (e)) | ((b) != (e)));
    if (b == e) {
      V[n].val = T(VEC[b]), V[n].b = b, V[n].e = e;
    } else {
      int m = (b + e) / 2;
      create(VEC, b, m);
      create(VEC, m + 1, e);
      V[n].join(V[(((b) + (m)) | ((b) != (m)))],
                V[(((m + 1) + (e)) | ((m + 1) != (e)))]);
    }
  }
  T query(int i, int j, int b = 0, int e = -1) {
    if (e == -1) e = N - 1;
    int n = (((b) + (e)) | ((b) != (e)));
    if (i <= b && e <= j) {
      return V[n].val;
    } else {
      int m = (b + e) / 2;
      V[n].pushDown(V[(((b) + (m)) | ((b) != (m)))],
                    V[(((m + 1) + (e)) | ((m + 1) != (e)))]);
      if (i > m) return query(i, j, m + 1, e);
      if (j <= m) return query(i, j, b, m);
      return query(i, j, b, m) + query(i, j, m + 1, e);
    }
  }
  int findOkPrefix(int i, const function<bool(T)> &isOk) {
    static int stk[50];
    int ssz = 0;
    stk[ssz++] = ((((0) + (N - 1)) | ((0) != (N - 1))));
    T acum;
    int sz = 0;
    while (ssz > 0) {
      int t = stk[--ssz];
      Node &n = V[t];
      int m = (n.b + n.e) / 2;
      if (n.e < i) continue;
      T newAcum = sz == 0 ? n.val : (acum + n.val);
      if (i <= n.b) {
        if (isOk(newAcum)) {
          sz += n.e - n.b + 1;
          acum = newAcum;
        } else {
          if (n.b == n.e) return sz;
          n.pushDown(V[(((n.b) + (m)) | ((n.b) != (m)))],
                     V[(((m + 1) + (n.e)) | ((m + 1) != (n.e)))]);
          stk[ssz++] = ((((m + 1) + (n.e)) | ((m + 1) != (n.e))));
          stk[ssz++] = ((((n.b) + (m)) | ((n.b) != (m))));
        }
      } else {
        if (n.b == n.e) continue;
        n.pushDown(V[(((n.b) + (m)) | ((n.b) != (m)))],
                   V[(((m + 1) + (n.e)) | ((m + 1) != (n.e)))]);
        stk[ssz++] = ((((m + 1) + (n.e)) | ((m + 1) != (n.e))));
        stk[ssz++] = ((((n.b) + (m)) | ((n.b) != (m))));
      }
    }
    return sz;
  }
  void update(int i, int j, const U &v, int b = 0, int e = -1) {
    if (e == -1) e = N - 1;
    int n = (((b) + (e)) | ((b) != (e)));
    if (i <= b && e <= j) {
      V[n].update(v.trim(max(b - i, 0), max(j - e, 0)));
    } else if (i > e || j < b)
      return;
    else {
      int m = (b + e) / 2;
      int l = (((b) + (m)) | ((b) != (m))),
          r = (((m + 1) + (e)) | ((m + 1) != (e)));
      V[n].pushDown(V[l], V[r]);
      update(i, j, v, b, m);
      update(i, j, v, m + 1, e);
      V[n].join(V[l], V[r]);
    }
  }
};
int PR[62], IPR[62];
unsigned long long encode(long long n) {
  unsigned long long primes = 0;
  for (int i = 0; i < 62 && n > 1; ++i) {
    if (n % PR[i] == 0) {
      primes |= 1LL << i;
    }
  }
  return primes;
}
long long mul(long long a, long long b) { return a * b % 1000000007; }
long long mul(long long a, long long b, long long c) {
  return a * b % 1000000007 * c % 1000000007;
}
int mpow(int b, int e) {
  if (e == 0) return 1;
  int sq = mpow(b, e >> 1);
  sq = (1LL * sq * sq) % 1000000007;
  return (e & 1) ? (1LL * sq * b) % 1000000007 : sq;
}
struct Phi {
  unsigned long long primes;
  long long prod;
  Phi(int n = 1) {
    prod = n;
    primes = encode(n);
  }
  Phi operator+(const Phi &a) const {
    Phi r;
    r.primes = primes | a.primes;
    r.prod = mul(prod, a.prod);
    return r;
  }
  long long get() const {
    long long r = prod;
    for (int i = 0; i < 62; ++i) {
      if (primes & (1LL << i)) {
        r = mul(r, PR[i] - 1, IPR[i]);
      }
    }
    return r;
  }
};
struct Add {
  unsigned long long primes;
  long long factor;
  int sz;
  Add(unsigned long long primes = 0, long long factor = 1, int sz = 1)
      : primes(primes), factor(factor), sz(sz) {}
  Add trim(int l, int r) const { return Add(primes, factor, sz - l - r); }
  void operator+=(const Add &a) {
    factor = factor * a.factor % 1000000007;
    primes |= a.primes;
    sz = a.sz;
  }
  void operator()(Phi &a) const {
    a.primes |= primes;
    a.prod = mul(a.prod, mpow(factor, sz));
  }
};
void build() {
  vector<int> P;
  vector<int> PRI(301, 1);
  for (int i = 2; i <= 300; ++i) {
    if (PRI[i]) {
      PR[P.size()] = i;
      IPR[P.size()] = mpow(i, 1000000007 - 2);
      P.push_back(i);
    }
    for (int j = 2 * i; j < PRI.size(); j += i) {
      PRI[j] = 0;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  build();
  int N, Q;
  cin >> N >> Q;
  SegmentTree<Phi, Add> ST(N);
  vector<int> V(N);
  for (int i = 0; i < N; ++i) {
    cin >> V[i];
  }
  ST.create(V);
  for (int i = 0; i < Q; ++i) {
    string c;
    cin >> c;
    if (c == "TOTIENT") {
      int l, r;
      cin >> l >> r;
      l--;
      r--;
      cout << ST.query(l, r).get() << endl;
    } else {
      int l, r, x;
      cin >> l >> r >> x;
      l--;
      r--;
      ST.update(l, r, Add(encode(x), x, r - l + 1));
    }
  }
}
