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;
const long long maxN = 4e5 + 10;
const long long mod = 1e9 + 7;
long long n, q, ngto[333], mask[333], inv[333];
vector<long long> nto;
void sang() {
  for (long long i = 2; i <= 300; ++i) {
    if (ngto[i] == 0) {
      nto.push_back(i);
      for (long long j = i * i; j <= 300; j += i) ngto[j] = 1;
    }
  }
  for (long long i = 2; i <= 300; ++i)
    for (long long j = 0; j < 62; ++j)
      if (i % nto[j] == 0) mask[i] |= (1ll << j);
}
long long Pow(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b % 2 == 0) {
      a = a * a % mod;
      b /= 2;
    } else {
      ans = ans * a % mod;
      b -= 1;
    }
  }
  return ans;
}
struct ITree {
  long long IT[maxN * 4], lazy[maxN * 4], IT2[maxN * 4], lazy2[maxN * 4];
  void pushdown(long long x, long long l, long long r) {
    if (lazy[x] == 1) return;
    IT[x] = IT[x] * Pow(lazy[x], r - l + 1) % mod;
    if (l != r) {
      lazy[x * 2] = lazy[x * 2] * lazy[x] % mod;
      lazy[x * 2 + 1] = lazy[x * 2 + 1] * lazy[x] % mod;
    }
    lazy[x] = 1;
  }
  void pushdown2(long long x, long long l, long long r) {
    if (lazy2[x] == 0) return;
    IT2[x] |= lazy2[x];
    if (l != r) {
      lazy2[x * 2] |= lazy2[x];
      lazy2[x * 2 + 1] |= lazy2[x];
    }
    lazy2[x] = 0;
  }
  void update(long long x, long long l, long long r, long long u, long long v,
              long long val) {
    pushdown(x, l, r);
    pushdown2(x, l, r);
    if (r < u || v < l) return;
    if (u <= l && r <= v) {
      lazy[x] = lazy[x] * val % mod;
      pushdown(x, l, r);
      lazy2[x] |= mask[val];
      pushdown2(x, l, r);
      return;
    }
    long long mid = (l + r) / 2;
    update(x * 2, l, mid, u, v, val);
    update(x * 2 + 1, mid + 1, r, u, v, val);
    IT[x] = IT[x * 2] * IT[x * 2 + 1] % mod;
    IT2[x] = (IT2[x * 2] | IT2[x * 2 + 1]);
  }
  long long query(long long x, long long l, long long r, long long u,
                  long long v) {
    pushdown(x, l, r);
    if (r < u || v < l) return 1;
    if (u <= l && r <= v) return IT[x];
    long long mid = (l + r) / 2;
    long long p1 = query(x * 2, l, mid, u, v);
    long long p2 = query(x * 2 + 1, mid + 1, r, u, v);
    return p1 * p2 % mod;
  }
  long long query2(long long x, long long l, long long r, long long u,
                   long long v) {
    pushdown2(x, l, r);
    if (r < u || v < l) return 0;
    if (u <= l && r <= v) return IT2[x];
    long long mid = (l + r) / 2;
    long long p1 = query2(x * 2, l, mid, u, v);
    long long p2 = query2(x * 2 + 1, mid + 1, r, u, v);
    return (p1 | p2);
  }
} tree;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  sang();
  cin >> n >> q;
  fill_n(tree.IT, maxN * 4, 1);
  fill_n(tree.lazy, maxN * 4, 1);
  for (long long i = 0; i < 62; ++i) inv[i] = Pow(nto[i], mod - 2);
  for (long long i = 1; i <= n; ++i) {
    long long a;
    cin >> a;
    tree.update(1, 1, n, i, i, a);
  }
  for (long long i = 1; i <= q; ++i) {
    string type;
    cin >> type;
    if (type[0] == 'M') {
      long long l, r, val;
      cin >> l >> r >> val;
      tree.update(1, 1, n, l, r, val);
    } else {
      long long l, r;
      cin >> l >> r;
      long long ans = tree.query(1, 1, n, l, r);
      long long Mask = tree.query2(1, 1, n, l, r);
      for (long long i = 0; i < 62; ++i) {
        if ((Mask & (1ll << i)) == 0) continue;
        ans = ans * (nto[i] - 1) % mod;
        ans = ans * inv[i] % mod;
      }
      cout << ans << "\n";
    }
  }
}
