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>
const long long mod = (long long)1000000000 + 7;
const long long inf = (long long)1e18;
const long double e = 2.718281828459;
const long double pi = 3.141592653;
const long double EPS = 1e-9;
using namespace std;
template <class T>
istream &operator>>(istream &in, vector<T> &arr) {
  for (T &cnt : arr) {
    in >> cnt;
  }
  return in;
};
long long binpow(long long a, long long b) {
  if (b == 0) {
    return 1;
  }
  if (b & 1) {
    return (binpow(a, b - 1) * a) % mod;
  }
  long long res = binpow(a, b / 2);
  return (res * res) % mod;
}
vector<long long> prod_t, prod_upd, sz, bit_t, bit_upd, arr;
void push_p(long long v) {
  if (prod_upd[v] == 1) {
    return;
  }
  prod_t[v] = (prod_t[v] * binpow(prod_upd[v], sz[v])) % mod;
  if (sz[v] != 1) {
    prod_upd[v * 2] = (prod_upd[v * 2] * prod_upd[v]) % mod;
    prod_upd[v * 2 + 1] = (prod_upd[v * 2 + 1] * prod_upd[v]) % mod;
  }
  prod_upd[v] = 1;
}
void push_b(long long v) {
  bit_t[v] |= bit_upd[v];
  if (sz[v] != 1) {
    bit_upd[v * 2] |= bit_upd[v];
    bit_upd[v * 2 + 1] |= bit_upd[v];
  }
  bit_upd[v] = 0;
}
void build(long long v, long long l, long long r) {
  if (l == r) {
    prod_t[v] = arr[l];
    sz[v] = 1;
    prod_upd[v] = 1;
    return;
  }
  long long mid = (l + r) / 2;
  build(v * 2, l, mid);
  build(v * 2 + 1, mid + 1, r);
  prod_t[v] = (prod_t[v * 2] * prod_t[v * 2 + 1]) % mod;
  sz[v] = sz[v * 2 + 1] + sz[v * 2];
  prod_upd[v] = 1;
}
long long pq(long long v, long long l, long long r, long long ql,
             long long qr) {
  push_p(v);
  if (l > qr or r < ql) {
    return 1;
  }
  if (l >= ql and r <= qr) {
    return prod_t[v];
  }
  long long mid = (l + r) / 2;
  return (pq(v * 2, l, mid, ql, qr) * pq(v * 2 + 1, mid + 1, r, ql, qr)) % mod;
}
void pu(long long v, long long l, long long r, long long ql, long long qr,
        long long val) {
  push_p(v);
  if (l > qr or r < ql) {
    return;
  }
  if (l >= ql and r <= qr) {
    prod_upd[v] *= val;
    prod_upd[v] %= mod;
    push_p(v);
    return;
  }
  long long mid = (l + r) / 2;
  pu(v * 2, l, mid, ql, qr, val);
  pu(v * 2 + 1, mid + 1, r, ql, qr, val);
  prod_t[v] = (prod_t[v * 2] * prod_t[v * 2 + 1]) % mod;
}
long long bq(long long v, long long l, long long r, long long ql,
             long long qr) {
  push_b(v);
  if (l > qr or r < ql) {
    return 0;
  }
  if (l >= ql and r <= qr) {
    return bit_t[v];
  }
  long long mid = (l + r) / 2;
  return bq(v * 2, l, mid, ql, qr) | bq(v * 2 + 1, mid + 1, r, ql, qr);
}
void bu(long long v, long long l, long long r, long long ql, long long qr,
        long long val) {
  push_b(v);
  if (l > qr or r < ql) {
    return;
  }
  if (l >= ql and r <= qr) {
    bit_upd[v] |= val;
    push_b(v);
    return;
  }
  long long mid = (l + r) / 2;
  bu(v * 2, l, mid, ql, qr, val);
  bu(v * 2 + 1, mid + 1, r, ql, qr, val);
  bit_t[v] = bit_t[v * 2] | bit_t[v * 2 + 1];
}
void solve() {
  vector<long long> erat(301, 1), primes(64), inv(64);
  for (long long i = 2; i < 301; i++) {
    if (erat[i] == 1) {
      for (long long j = i * i; j < 301; j += i) {
        erat[j] = -1;
      }
    }
  }
  int cnt = 0;
  for (int i = 2; i < 301; i++) {
    if (erat[i] != -1) {
      erat[i] = cnt;
      primes[cnt] = i;
      inv[cnt] = ((primes[cnt] - 1) * binpow(primes[cnt], mod - 2)) % mod;
      cnt++;
    }
  }
  vector<long long> masks(301);
  for (int i = 2; i < 301; i++) {
    long long m = 0;
    for (int j = 2; j < 301; j++) {
      if (i % j == 0 and erat[j] != -1) {
        m = (m | (1LL << erat[j]));
      }
    }
    masks[i] = m;
  }
  long long n, q;
  cin >> n >> q;
  arr.resize(n);
  bit_t.resize(4 * n);
  bit_upd.resize(4 * n);
  prod_t.resize(4 * n);
  prod_upd.resize(4 * n);
  sz.resize(4 * n);
  cin >> arr;
  build(1, 0, n - 1);
  for (int i = 0; i < n; i++) {
    bu(1, 0, n - 1, i, i, masks[arr[i]]);
  }
  while (q--) {
    string cmd;
    cin >> cmd;
    if (cmd[0] == 'M') {
      long long l, r, x;
      cin >> l >> r >> x;
      pu(1, 0, n - 1, l - 1, r - 1, x);
      bu(1, 0, n - 1, l - 1, r - 1, masks[x]);
    } else {
      long long l, r;
      cin >> l >> r;
      l--;
      r--;
      long long product = pq(1, 0, n - 1, l, r);
      long long m1 = bq(1, 0, n - 1, l, r);
      for (int i = 0; i < 62; i++) {
        if ((m1 & (1LL << i)) != 0) {
          product = (product * inv[i]) % mod;
        }
      }
      cout << product << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(30);
  srand(time(0));
  solve();
  return 0;
}
