#include <bits/stdc++.h>
using namespace std;
const unsigned long long MAXX = 301;
const unsigned long long MAXN = 411111;
const unsigned long long mod = 1e9 + 7;
unsigned long long n, m;
vector<unsigned long long> a, primes, lp, idx, inv;
bitset<100> zero;
unsigned long long pw(unsigned long long a, unsigned long long p) {
  unsigned long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    p >>= 1;
  }
  return ans;
}
void init() {
  lp.resize(MAXX), idx.resize(MAXX), inv.resize(MAXX);
  for (unsigned long long i = 2; i < MAXX; i++) {
    if (lp[i] == 0) lp[i] = i, primes.push_back(i);
    for (unsigned long long j = 0;
         j < primes.size() && primes[j] <= lp[i] && i * primes[j] < MAXX; j++)
      lp[i * primes[j]] = primes[j];
  }
  m = primes.size();
  for (unsigned long long i = 0; i < m; i++)
    idx[primes[i]] = i, inv[primes[i]] = pw(primes[i], mod - 2);
}
bitset<100> get_fact(unsigned long long x) {
  bitset<100> ans;
  while (x != 1) {
    unsigned long long cur_p = lp[x];
    ans.set(idx[cur_p]);
    while (x % cur_p == 0) x /= cur_p;
  }
  return ans;
}
struct node {
  bitset<100> mask, to_push_mask;
  unsigned long long prod, to_push_prod, len;
};
node tree[4 * MAXN];
void build(unsigned long long tl, unsigned long long tr, unsigned long long v) {
  tree[v].to_push_prod = tree[v].prod = 1;
  tree[v].len = tr - tl + 1;
  if (tl == tr) {
    tree[v].prod = a[tl];
    tree[v].mask = get_fact(a[tl]);
    return;
  }
  unsigned long long mid = (tl + tr) >> 1;
  build(tl, mid, v << 1);
  build(mid + 1, tr, v << 1 | 1);
  tree[v].mask = tree[v << 1].mask | tree[v << 1 | 1].mask;
  tree[v].prod = (tree[v << 1].prod * tree[v << 1 | 1].prod) % mod;
}
void upd(unsigned long long v, unsigned long long par) {
  bitset<100> msk = tree[par].to_push_mask;
  unsigned long long x = tree[par].to_push_prod;
  tree[v].to_push_mask |= msk;
  tree[v].to_push_prod = (tree[v].to_push_prod * x) % mod;
  tree[v].mask |= msk;
  tree[v].prod = (tree[v].prod * pw(x, tree[v].len)) % mod;
}
void push(unsigned long long v) {
  if ((v << 1 | 1) >= 4 * MAXN || tree[v].to_push_prod == 1) return;
  upd(v << 1, v);
  upd(v << 1 | 1, v);
  tree[v].to_push_mask &= zero;
  tree[v].to_push_prod = 1;
}
void update(unsigned long long tl, unsigned long long tr, unsigned long long v,
            unsigned long long l, unsigned long long r, unsigned long long x,
            bitset<100> fact) {
  if (r < tl || l > tr) return;
  if (l <= tl && tr <= r) {
    tree[v].prod = (tree[v].prod * pw(x, tree[v].len)) % mod;
    tree[v].mask |= fact;
    tree[v].to_push_prod = (tree[v].to_push_prod * x) % mod;
    tree[v].to_push_mask |= fact;
    return;
  }
  push(v);
  unsigned long long mid = (tl + tr) >> 1;
  update(tl, mid, v << 1, l, r, x, fact);
  update(mid + 1, tr, v << 1 | 1, l, r, x, fact);
  tree[v].mask = tree[v << 1].mask | tree[v << 1 | 1].mask;
  tree[v].prod = (tree[v << 1].prod * tree[v << 1 | 1].prod) % mod;
}
pair<bitset<100>, unsigned long long> query(unsigned long long tl,
                                            unsigned long long tr,
                                            unsigned long long v,
                                            unsigned long long l,
                                            unsigned long long r) {
  if (r < tl || l > tr) return {bitset<100>("0"), 1};
  push(v);
  if (l <= tl && tr <= r) {
    return {tree[v].mask, tree[v].prod};
  }
  unsigned long long mid = (tl + tr) >> 1;
  pair<bitset<100>, unsigned long long> one = query(tl, mid, v << 1, l, r);
  pair<bitset<100>, unsigned long long> two =
      query(mid + 1, tr, v << 1 | 1, l, r);
  return {one.first | two.first, (one.second * two.second) % mod};
}
unsigned long long query(unsigned long long l, unsigned long long r) {
  pair<bitset<100>, unsigned long long> ans = query(0, n - 1, 1, l, r);
  unsigned long long res = ans.second;
  for (unsigned long long i = 0; i < m; i++) {
    if (!ans.first[i]) continue;
    unsigned long long p = primes[i];
    res = (res - (res * inv[p]) % mod + mod) % mod;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  init();
  unsigned long long q;
  cin >> n >> q;
  a.resize(n);
  for (unsigned long long i = 0; i < n; i++) cin >> a[i];
  build(0, n - 1, 1);
  while (q--) {
    string type;
    cin >> type;
    if (type[0] == 'M') {
      unsigned long long l, r, x;
      cin >> l >> r >> x;
      l--, r--;
      bitset<100> fact = get_fact(x);
      update(0, n - 1, 1, l, r, x, fact);
    } else {
      unsigned long long l, r;
      cin >> l >> r;
      l--, r--;
      unsigned long long ans = query(l, r);
      cout << ans << '\n';
    }
  }
  return 0;
}

### Prompt

Please create a solution in CPP to the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const unsigned long long MAXX = 301;
const unsigned long long MAXN = 411111;
const unsigned long long mod = 1e9 + 7;
unsigned long long n, m;
vector<unsigned long long> a, primes, lp, idx, inv;
bitset<100> zero;
unsigned long long pw(unsigned long long a, unsigned long long p) {
  unsigned long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    p >>= 1;
  }
  return ans;
}
void init() {
  lp.resize(MAXX), idx.resize(MAXX), inv.resize(MAXX);
  for (unsigned long long i = 2; i < MAXX; i++) {
    if (lp[i] == 0) lp[i] = i, primes.push_back(i);
    for (unsigned long long j = 0;
         j < primes.size() && primes[j] <= lp[i] && i * primes[j] < MAXX; j++)
      lp[i * primes[j]] = primes[j];
  }
  m = primes.size();
  for (unsigned long long i = 0; i < m; i++)
    idx[primes[i]] = i, inv[primes[i]] = pw(primes[i], mod - 2);
}
bitset<100> get_fact(unsigned long long x) {
  bitset<100> ans;
  while (x != 1) {
    unsigned long long cur_p = lp[x];
    ans.set(idx[cur_p]);
    while (x % cur_p == 0) x /= cur_p;
  }
  return ans;
}
struct node {
  bitset<100> mask, to_push_mask;
  unsigned long long prod, to_push_prod, len;
};
node tree[4 * MAXN];
void build(unsigned long long tl, unsigned long long tr, unsigned long long v) {
  tree[v].to_push_prod = tree[v].prod = 1;
  tree[v].len = tr - tl + 1;
  if (tl == tr) {
    tree[v].prod = a[tl];
    tree[v].mask = get_fact(a[tl]);
    return;
  }
  unsigned long long mid = (tl + tr) >> 1;
  build(tl, mid, v << 1);
  build(mid + 1, tr, v << 1 | 1);
  tree[v].mask = tree[v << 1].mask | tree[v << 1 | 1].mask;
  tree[v].prod = (tree[v << 1].prod * tree[v << 1 | 1].prod) % mod;
}
void upd(unsigned long long v, unsigned long long par) {
  bitset<100> msk = tree[par].to_push_mask;
  unsigned long long x = tree[par].to_push_prod;
  tree[v].to_push_mask |= msk;
  tree[v].to_push_prod = (tree[v].to_push_prod * x) % mod;
  tree[v].mask |= msk;
  tree[v].prod = (tree[v].prod * pw(x, tree[v].len)) % mod;
}
void push(unsigned long long v) {
  if ((v << 1 | 1) >= 4 * MAXN || tree[v].to_push_prod == 1) return;
  upd(v << 1, v);
  upd(v << 1 | 1, v);
  tree[v].to_push_mask &= zero;
  tree[v].to_push_prod = 1;
}
void update(unsigned long long tl, unsigned long long tr, unsigned long long v,
            unsigned long long l, unsigned long long r, unsigned long long x,
            bitset<100> fact) {
  if (r < tl || l > tr) return;
  if (l <= tl && tr <= r) {
    tree[v].prod = (tree[v].prod * pw(x, tree[v].len)) % mod;
    tree[v].mask |= fact;
    tree[v].to_push_prod = (tree[v].to_push_prod * x) % mod;
    tree[v].to_push_mask |= fact;
    return;
  }
  push(v);
  unsigned long long mid = (tl + tr) >> 1;
  update(tl, mid, v << 1, l, r, x, fact);
  update(mid + 1, tr, v << 1 | 1, l, r, x, fact);
  tree[v].mask = tree[v << 1].mask | tree[v << 1 | 1].mask;
  tree[v].prod = (tree[v << 1].prod * tree[v << 1 | 1].prod) % mod;
}
pair<bitset<100>, unsigned long long> query(unsigned long long tl,
                                            unsigned long long tr,
                                            unsigned long long v,
                                            unsigned long long l,
                                            unsigned long long r) {
  if (r < tl || l > tr) return {bitset<100>("0"), 1};
  push(v);
  if (l <= tl && tr <= r) {
    return {tree[v].mask, tree[v].prod};
  }
  unsigned long long mid = (tl + tr) >> 1;
  pair<bitset<100>, unsigned long long> one = query(tl, mid, v << 1, l, r);
  pair<bitset<100>, unsigned long long> two =
      query(mid + 1, tr, v << 1 | 1, l, r);
  return {one.first | two.first, (one.second * two.second) % mod};
}
unsigned long long query(unsigned long long l, unsigned long long r) {
  pair<bitset<100>, unsigned long long> ans = query(0, n - 1, 1, l, r);
  unsigned long long res = ans.second;
  for (unsigned long long i = 0; i < m; i++) {
    if (!ans.first[i]) continue;
    unsigned long long p = primes[i];
    res = (res - (res * inv[p]) % mod + mod) % mod;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  init();
  unsigned long long q;
  cin >> n >> q;
  a.resize(n);
  for (unsigned long long i = 0; i < n; i++) cin >> a[i];
  build(0, n - 1, 1);
  while (q--) {
    string type;
    cin >> type;
    if (type[0] == 'M') {
      unsigned long long l, r, x;
      cin >> l >> r >> x;
      l--, r--;
      bitset<100> fact = get_fact(x);
      update(0, n - 1, 1, l, r, x, fact);
    } else {
      unsigned long long l, r;
      cin >> l >> r;
      l--, r--;
      unsigned long long ans = query(l, r);
      cout << ans << '\n';
    }
  }
  return 0;
}

```