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;
bool endline = false;
template <class T>
istream& operator>>(istream& inp, vector<T>& v) {
  for (auto& it : v) inp >> it;
  return inp;
}
template <class T>
ostream& operator<<(ostream& out, vector<T>& v) {
  for (auto& it : v) out << it << (endline ? "\n" : " ");
  return out;
}
template <class T, class U>
istream& operator>>(istream& inp, pair<T, U>& v) {
  inp >> v.first >> v.second;
  return inp;
}
template <class T, class U>
ostream& operator<<(ostream& out, pair<T, U>& v) {
  out << v.first << ' ' << v.second;
  return out;
}
void debug() { cout << endl; }
template <typename H, typename... T>
void debug(H a, T... b) {
  cout << a << ' ';
  debug(b...);
}
void FAST_IO(string filein = "", string fileout = "") {
  if (fopen(filein.c_str(), "r")) {
    freopen(filein.c_str(), "r", stdin);
    freopen(fileout.c_str(), "w", stdout);
  }
  cin.tie(0), cout.tie(0)->sync_with_stdio(0);
}
void Hollwo_Pelw();
signed main() {
  FAST_IO(".inp", ".out");
  int testcases = 1;
  for (int test = 1; test <= testcases; test++) {
    Hollwo_Pelw();
  }
  return 0;
}
const int allmod[3] = {(int)1e9 + 7, 998244353, (int)1e9 + 9};
const int mod = allmod[0];
const int MAXN = 4e5 + 5;
const int inf = 2e9;
const long long linf = 1e18;
long long mask[303], pr[303], C[303];
vector<long long> primes;
long long binpow(long long a, long long x) {
  long long r = 1;
  while (x) {
    if (x & 1) r = r * a % mod;
    x >>= 1;
    a = a * a % mod;
  }
  return r;
}
struct node {
  long long msk, product, lzmsk, lzproduct;
} st[MAXN << 2];
long long n, q, a[MAXN];
node merge(node l, node r) {
  return {l.msk | r.msk, l.product * r.product % mod, 0, 1};
}
void build(long long id, long long tl, long long tr) {
  if (tl == tr) {
    st[id] = {mask[a[tl]], a[tl], 0, 1};
  } else {
    long long tm = tl + tr >> 1;
    build(id << 1, tl, tm), build(id << 1 | 1, tm + 1, tr);
    st[id] = merge(st[id << 1], st[id << 1 | 1]);
  }
}
void apply(long long id, long long tl, long long tr, long long x,
           long long msk) {
  st[id].msk |= msk;
  st[id].lzmsk |= msk;
  (st[id].product *= binpow(x, tr - tl + 1)) %= mod;
  (st[id].lzproduct *= x) %= mod;
}
void push(long long id, long long tl, long long tr) {
  long long tm = tl + tr >> 1;
  apply(id << 1, tl, tm, st[id].lzproduct, st[id].lzmsk);
  apply(id << 1 | 1, tm + 1, tr, st[id].lzproduct, st[id].lzmsk);
  st[id].lzproduct = 1;
  st[id].lzmsk = 0;
}
void upd(long long l, long long r, long long x, long long id = 1,
         long long tl = 1, long long tr = n) {
  if (l > r || tl > r || l > tr) return;
  if (l <= tl && tr <= r) return apply(id, tl, tr, x, mask[x]);
  long long tm = tl + tr >> 1;
  push(id, tl, tr);
  upd(l, r, x, id << 1, tl, tm), upd(l, r, x, id << 1 | 1, tm + 1, tr);
  st[id] = merge(st[id << 1], st[id << 1 | 1]);
}
node query(long long l, long long r, long long id = 1, long long tl = 1,
           long long tr = n) {
  if (l > r || tl > r || l > tr) return {0, 1, 0, 1};
  if (l <= tl && tr <= r) return st[id];
  long long tm = tl + tr >> 1;
  push(id, tl, tr);
  return merge(query(l, r, id << 1, tl, tm),
               query(l, r, id << 1 | 1, tm + 1, tr));
}
long long calc(node x) {
  long long r = x.product;
  for (long long i = 0; i < primes.size(); i++) {
    if (x.msk >> i & 1) {
      r = r * C[primes[i]] % mod;
    }
  }
  return r;
}
void Hollwo_Pelw() {
  for (long long i = 2; i <= 300; i++) pr[i] = 1;
  for (long long i = 2; i <= 300; i++) {
    if (pr[i]) {
      primes.push_back(i);
      for (long long j = i * i; j <= 300; j += i) pr[j] = 0;
      C[i] = (i - 1) * binpow(i, mod - 2) % mod;
    }
    for (long long j = 0; j < primes.size(); j++)
      if (i % primes[j] == 0) mask[i] |= 1ll << j;
  }
  cin >> n >> q;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  build(1, 1, n);
  while (q--) {
    string t;
    long long l, r, x;
    cin >> t >> l >> r;
    if (t[0] == 'T')
      cout << calc(query(l, r)) << "\n";
    else
      cin >> x, upd(l, r, x);
  }
}
