#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;
const ld EPS = 1e-9;
inline int cmp(ld first, ld second = 0, ld tol = EPS) {
  return (first <= second + tol) ? (first + tol < second) ? -1 : 0 : 1;
}
const int MOD = 1e9 + 7;
const int N = 4e5 + 10;
int n, q;
bool not_prime[310];
vector<int> primes;
int invMod[65];
ll allMsks[310];
void sieve() {
  for (int i = 2; i * i <= 300; i++)
    if (!not_prime[i])
      for (int j = i * i; j <= 300; j += i) not_prime[j] = true;
  for (int i = 2; i <= 300; i++)
    if (!not_prime[i]) primes.push_back(i);
}
int powMod(int b, ll p) {
  if (p < 0) return 0;
  int ret = 1;
  while (p) {
    if (p & 1) ret = (ret * 1LL * b) % MOD;
    p >>= 1;
    b = (b * 1LL * b) % MOD;
  }
  return ret;
}
int _invMod(int b) { return powMod(b, MOD - 2); }
struct _multSegTree {
  int tree[4 * N], lazy[4 * N];
  void clean() {
    for (int i = 0; i < 4 * N; i++) tree[i] = lazy[i] = 1;
  }
  void prop(int p, int l, int r) {
    if (l < r) {
      lazy[2 * p] = (lazy[2 * p] * 1LL * lazy[p]) % MOD;
      lazy[2 * p + 1] = (lazy[2 * p + 1] * 1LL * lazy[p]) % MOD;
    }
    tree[p] = (powMod(lazy[p], (r - l + 1)) * 1LL * tree[p]) % MOD;
    lazy[p] = 1;
  }
  void upd(int l, int r, int v, int p = 1, int tl = 1, int tr = n) {
    prop(p, tl, tr);
    if (l <= tl and tr <= r) {
      lazy[p] = v;
      prop(p, tl, tr);
      return;
    } else if (tr < l or r < tl)
      return;
    int md = (tl + tr) / 2;
    upd(l, r, v, 2 * p, tl, md);
    upd(l, r, v, 2 * p + 1, md + 1, tr);
    tree[p] = (tree[2 * p] * 1LL * tree[2 * p + 1]) % MOD;
  }
  int qry(int l, int r, int p = 1, int tl = 1, int tr = n) {
    prop(p, tl, tr);
    if (l <= tl and tr <= r)
      return tree[p];
    else if (tr < l or r < tl)
      return 1;
    int md = (tl + tr) / 2;
    int ret =
        (qry(l, r, 2 * p, tl, md) * 1LL * qry(l, r, 2 * p + 1, md + 1, tr)) %
        MOD;
    tree[p] = (tree[2 * p] * 1LL * tree[2 * p + 1]) % MOD;
    return ret;
  }
};
struct _bitSegTree {
  ll tree[4 * N], lazy[4 * N];
  void clean() {
    for (int i = 0; i < 4 * N; i++) tree[i] = lazy[i] = 0;
  }
  void prop(int p, int l, int r) {
    if (l < r) {
      lazy[2 * p] |= lazy[p];
      lazy[2 * p + 1] |= lazy[p];
    }
    tree[p] |= lazy[p];
    lazy[p] = 0;
  }
  void upd(int l, int r, ll msk, int p = 1, int tl = 1, int tr = n) {
    prop(p, tl, tr);
    if (l <= tl and tr <= r) {
      lazy[p] |= msk;
      prop(p, tl, tr);
      return;
    } else if (r < tl or tr < l)
      return;
    int md = (tl + tr) / 2;
    upd(l, r, msk, 2 * p, tl, md);
    upd(l, r, msk, 2 * p + 1, md + 1, tr);
    tree[p] = tree[2 * p] | tree[2 * p + 1];
  }
  void upd(int l, int r, int v) {
    ll &msk = allMsks[v];
    if (msk == -1) {
      msk = 0;
      for (int i = 0; i < ((int)(primes).size()); i++)
        if (v % primes[i] == 0) msk |= (1LL << i);
    }
    upd(l, r, msk);
  }
  ll qry(int l, int r, int p = 1, int tl = 1, int tr = n) {
    prop(p, tl, tr);
    if (l <= tl and tr <= r)
      return tree[p];
    else if (r < tl or tr < l)
      return 0;
    int md = (tl + tr) / 2;
    ll ret = qry(l, r, 2 * p, tl, md) | qry(l, r, 2 * p + 1, md + 1, tr);
    tree[p] = tree[2 * p] | tree[2 * p + 1];
    return ret;
  }
};
_multSegTree multSeg;
_bitSegTree bitSeg;
ll qry(int l, int r) {
  ll ret = multSeg.qry(l, r);
  ll msk = bitSeg.qry(l, r);
  for (int i = 0; i < ((int)(primes).size()); i++)
    if ((msk & (1LL << i))) {
      ret = (ret * (primes[i] - 1)) % MOD;
      ret = (ret * invMod[i]) % MOD;
    }
  return ret;
}
int main() {
  for (int i = 1; i <= 300; i++) allMsks[i] = -1;
  sieve();
  multSeg.clean();
  bitSeg.clean();
  for (int i = 0; i < ((int)(primes).size()); i++)
    invMod[i] = _invMod(primes[i]);
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= n; i++) {
    int first;
    scanf("%d", &first);
    multSeg.upd(i, i, first);
    bitSeg.upd(i, i, first);
  }
  char arr[15];
  int l, r, v;
  while (q--) {
    scanf("%s %d %d", arr, &l, &r);
    if (l > r) swap(l, r);
    if (arr[0] == 'M') {
      scanf("%d", &v);
      multSeg.upd(l, r, v);
      bitSeg.upd(l, r, v);
    } else
      printf("%lld\n", (qry(l, r) + MOD) % MOD);
  }
  return 0;
}

### Prompt

Generate a Cpp solution 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;
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;
const ld EPS = 1e-9;
inline int cmp(ld first, ld second = 0, ld tol = EPS) {
  return (first <= second + tol) ? (first + tol < second) ? -1 : 0 : 1;
}
const int MOD = 1e9 + 7;
const int N = 4e5 + 10;
int n, q;
bool not_prime[310];
vector<int> primes;
int invMod[65];
ll allMsks[310];
void sieve() {
  for (int i = 2; i * i <= 300; i++)
    if (!not_prime[i])
      for (int j = i * i; j <= 300; j += i) not_prime[j] = true;
  for (int i = 2; i <= 300; i++)
    if (!not_prime[i]) primes.push_back(i);
}
int powMod(int b, ll p) {
  if (p < 0) return 0;
  int ret = 1;
  while (p) {
    if (p & 1) ret = (ret * 1LL * b) % MOD;
    p >>= 1;
    b = (b * 1LL * b) % MOD;
  }
  return ret;
}
int _invMod(int b) { return powMod(b, MOD - 2); }
struct _multSegTree {
  int tree[4 * N], lazy[4 * N];
  void clean() {
    for (int i = 0; i < 4 * N; i++) tree[i] = lazy[i] = 1;
  }
  void prop(int p, int l, int r) {
    if (l < r) {
      lazy[2 * p] = (lazy[2 * p] * 1LL * lazy[p]) % MOD;
      lazy[2 * p + 1] = (lazy[2 * p + 1] * 1LL * lazy[p]) % MOD;
    }
    tree[p] = (powMod(lazy[p], (r - l + 1)) * 1LL * tree[p]) % MOD;
    lazy[p] = 1;
  }
  void upd(int l, int r, int v, int p = 1, int tl = 1, int tr = n) {
    prop(p, tl, tr);
    if (l <= tl and tr <= r) {
      lazy[p] = v;
      prop(p, tl, tr);
      return;
    } else if (tr < l or r < tl)
      return;
    int md = (tl + tr) / 2;
    upd(l, r, v, 2 * p, tl, md);
    upd(l, r, v, 2 * p + 1, md + 1, tr);
    tree[p] = (tree[2 * p] * 1LL * tree[2 * p + 1]) % MOD;
  }
  int qry(int l, int r, int p = 1, int tl = 1, int tr = n) {
    prop(p, tl, tr);
    if (l <= tl and tr <= r)
      return tree[p];
    else if (tr < l or r < tl)
      return 1;
    int md = (tl + tr) / 2;
    int ret =
        (qry(l, r, 2 * p, tl, md) * 1LL * qry(l, r, 2 * p + 1, md + 1, tr)) %
        MOD;
    tree[p] = (tree[2 * p] * 1LL * tree[2 * p + 1]) % MOD;
    return ret;
  }
};
struct _bitSegTree {
  ll tree[4 * N], lazy[4 * N];
  void clean() {
    for (int i = 0; i < 4 * N; i++) tree[i] = lazy[i] = 0;
  }
  void prop(int p, int l, int r) {
    if (l < r) {
      lazy[2 * p] |= lazy[p];
      lazy[2 * p + 1] |= lazy[p];
    }
    tree[p] |= lazy[p];
    lazy[p] = 0;
  }
  void upd(int l, int r, ll msk, int p = 1, int tl = 1, int tr = n) {
    prop(p, tl, tr);
    if (l <= tl and tr <= r) {
      lazy[p] |= msk;
      prop(p, tl, tr);
      return;
    } else if (r < tl or tr < l)
      return;
    int md = (tl + tr) / 2;
    upd(l, r, msk, 2 * p, tl, md);
    upd(l, r, msk, 2 * p + 1, md + 1, tr);
    tree[p] = tree[2 * p] | tree[2 * p + 1];
  }
  void upd(int l, int r, int v) {
    ll &msk = allMsks[v];
    if (msk == -1) {
      msk = 0;
      for (int i = 0; i < ((int)(primes).size()); i++)
        if (v % primes[i] == 0) msk |= (1LL << i);
    }
    upd(l, r, msk);
  }
  ll qry(int l, int r, int p = 1, int tl = 1, int tr = n) {
    prop(p, tl, tr);
    if (l <= tl and tr <= r)
      return tree[p];
    else if (r < tl or tr < l)
      return 0;
    int md = (tl + tr) / 2;
    ll ret = qry(l, r, 2 * p, tl, md) | qry(l, r, 2 * p + 1, md + 1, tr);
    tree[p] = tree[2 * p] | tree[2 * p + 1];
    return ret;
  }
};
_multSegTree multSeg;
_bitSegTree bitSeg;
ll qry(int l, int r) {
  ll ret = multSeg.qry(l, r);
  ll msk = bitSeg.qry(l, r);
  for (int i = 0; i < ((int)(primes).size()); i++)
    if ((msk & (1LL << i))) {
      ret = (ret * (primes[i] - 1)) % MOD;
      ret = (ret * invMod[i]) % MOD;
    }
  return ret;
}
int main() {
  for (int i = 1; i <= 300; i++) allMsks[i] = -1;
  sieve();
  multSeg.clean();
  bitSeg.clean();
  for (int i = 0; i < ((int)(primes).size()); i++)
    invMod[i] = _invMod(primes[i]);
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= n; i++) {
    int first;
    scanf("%d", &first);
    multSeg.upd(i, i, first);
    bitSeg.upd(i, i, first);
  }
  char arr[15];
  int l, r, v;
  while (q--) {
    scanf("%s %d %d", arr, &l, &r);
    if (l > r) swap(l, r);
    if (arr[0] == 'M') {
      scanf("%d", &v);
      multSeg.upd(l, r, v);
      bitSeg.upd(l, r, v);
    } else
      printf("%lld\n", (qry(l, r) + MOD) % MOD);
  }
  return 0;
}

```