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;
int n, q, l, r, first, second, z, v[305];
vector<int> p, inv;
long long mod = 1e9 + 7, sg1[1600005], lz1[1600005], sg2[1600005], lz2[1600005],
          b[400005], a[400005];
string str;
void Build1(int nod = 1, int l = 1, int r = n) {
  if (l == r) {
    sg1[nod] = a[l];
    return;
  }
  int mid = (l + r) / 2;
  Build1(2 * nod, l, mid);
  Build1(2 * nod + 1, mid + 1, r);
  sg1[nod] = sg1[2 * nod] | sg1[2 * nod + 1];
}
void Build2(int nod = 1, int l = 1, int r = n) {
  lz2[nod] = 1;
  if (l == r) {
    sg2[nod] = b[l];
    return;
  }
  int mid = (l + r) / 2;
  Build2(2 * nod, l, mid);
  Build2(2 * nod + 1, mid + 1, r);
  sg2[nod] = sg2[2 * nod] * sg2[2 * nod + 1] % mod;
}
void Sift1(int nod, int l, int r) {
  sg1[nod] |= lz1[nod];
  if (l != r) {
    lz1[2 * nod] |= lz1[nod];
    lz1[2 * nod + 1] |= lz1[nod];
  }
  lz1[nod] = 0;
}
void Upd1(int lt, int rt, long long v, int nod = 1, int l = 1, int r = n) {
  Sift1(nod, l, r);
  if (l > rt || r < lt) return;
  if (l >= lt && r <= rt) {
    lz1[nod] |= v;
    Sift1(nod, l, r);
    return;
  }
  int mid = (l + r) / 2;
  Upd1(lt, rt, v, 2 * nod, l, mid);
  Upd1(lt, rt, v, 2 * nod + 1, mid + 1, r);
  sg1[nod] = sg1[2 * nod] | sg1[2 * nod + 1];
}
long long Qry1(int lt, int rt, int nod = 1, int l = 1, int r = n) {
  Sift1(nod, l, r);
  if (l > rt || r < lt) return 0;
  if (l >= lt && r <= rt) return sg1[nod];
  int mid = (l + r) / 2;
  return Qry1(lt, rt, 2 * nod, l, mid) | Qry1(lt, rt, 2 * nod + 1, mid + 1, r);
}
long long pwr(long long p, long long k) {
  if (k == 0) return 1;
  long long t = pwr(p, k / 2);
  t *= t;
  t %= mod;
  if (k % 2) t *= p, t %= mod;
  return t;
}
void Sift2(int nod, int l, int r) {
  sg2[nod] *= pwr(lz2[nod], (r - l + 1));
  sg2[nod] %= mod;
  if (l != r) {
    lz2[2 * nod] *= lz2[nod];
    lz2[2 * nod] %= mod;
    lz2[2 * nod + 1] *= lz2[nod];
    lz2[2 * nod + 1] %= mod;
  }
  lz2[nod] = 1;
}
void Upd2(int lt, int rt, long long v, int nod = 1, int l = 1, int r = n) {
  Sift2(nod, l, r);
  if (l > rt || r < lt) return;
  if (l >= lt && r <= rt) {
    lz2[nod] *= v;
    lz2[nod] %= mod;
    Sift2(nod, l, r);
    return;
  }
  int mid = (l + r) / 2;
  Upd2(lt, rt, v, 2 * nod, l, mid);
  Upd2(lt, rt, v, 2 * nod + 1, mid + 1, r);
  sg2[nod] = sg2[2 * nod] * sg2[2 * nod + 1] % mod;
}
long long Qry2(int lt, int rt, int nod = 1, int l = 1, int r = n) {
  Sift2(nod, l, r);
  if (l > rt || r < lt) return 1;
  if (l >= lt && r <= rt) return sg2[nod];
  int mid = (l + r) / 2;
  return Qry2(lt, rt, 2 * nod, l, mid) * Qry2(lt, rt, 2 * nod + 1, mid + 1, r) %
         mod;
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  for (int i = 2; i <= 300; i++) {
    if (!v[i]) {
      p.push_back(i);
      inv.push_back(pwr(i, mod - 2));
      v[i] = p.size() - 1;
      for (int j = 2 * i; j <= 300; j += i) {
        v[j] = 1;
      }
    }
  }
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> first;
    for (int j : p) {
      if (first % j == 0) a[i] |= (1ll << v[j]);
    }
    b[i] = first;
  }
  Build1();
  Build2();
  for (int i = 1; i <= q; i++) {
    cin >> str;
    if (str == "MULTIPLY") {
      cin >> l >> r >> first;
      long long second = 0;
      for (int j : p) {
        if (first % j == 0) second |= (1ll << v[j]);
      }
      Upd1(l, r, second);
      Upd2(l, r, first);
    } else {
      cin >> l >> r;
      long long ans = Qry2(l, r), t = Qry1(l, r);
      for (int i = 0; i < p.size(); i++) {
        if ((1ll << i) & t)
          ans *= (long long)(p[i] - 1) * inv[i] % mod, ans %= mod;
      }
      cout << ans << '\n';
    }
  }
}
