#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 400040, mod = 1000000007;
inline int read() {
  char ch = getchar();
  int x = 0, f = 0;
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
int n, q, pri[66], pl, a[maxn], inv[333], f[66], tag1[maxn * 4];
long long tag2[maxn * 4];
bool vis[333];
void init() {
  for (int i = (2); i <= (300); i++) {
    if (!vis[i]) pri[++pl] = i;
    for (int j = 1; j <= pl && i * pri[j] <= 300; j++) {
      vis[i * pri[j]] = true;
      if (i % pri[j] == 0) break;
    }
  }
  inv[1] = 1;
  for (int i = (2); i <= (300); i++)
    inv[i] = mod - 1ll * (mod / i) * inv[mod % i] % mod;
  for (int i = (1); i <= (pl); i++)
    f[i] = 1ll * inv[pri[i]] * (pri[i] - 1) % mod;
}
inline int qpow(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) ans = 1ll * ans * a % mod;
  return ans;
}
struct node {
  int pro;
  long long has;
} nd[maxn * 4];
void pushup(node &o, node l, node r) {
  o.has = l.has | r.has;
  o.pro = 1ll * l.pro * r.pro % mod;
}
void setmult(int o, int l, int r, int x, long long y) {
  tag1[o] = 1ll * tag1[o] * x % mod;
  tag2[o] |= y;
  nd[o].pro = 1ll * nd[o].pro * qpow(x, r - l + 1) % mod;
  nd[o].has |= y;
}
void pushdown(int o, int l, int r) {
  if (!tag2[o]) return;
  int mid = (l + r) >> 1;
  setmult(o << 1, l, mid, tag1[o], tag2[o]);
  setmult(o << 1 | 1, mid + 1, r, tag1[o], tag2[o]);
  tag1[o] = 1;
  tag2[o] = 0;
}
void build(int o, int l, int r) {
  tag1[o] = 1;
  tag2[o] = 0;
  if (l == r) {
    nd[o].pro = a[l];
    for (int i = (1); i <= (pl); i++)
      if (a[l] % pri[i] == 0) nd[o].has |= 1ll << (i - 1);
    return;
  }
  int mid = (l + r) >> 1;
  build(o << 1, l, mid);
  build(o << 1 | 1, mid + 1, r);
  pushup(nd[o], nd[o << 1], nd[o << 1 | 1]);
}
void mult(int o, int l, int r, int ql, int qr, int x, long long y) {
  if (l >= ql && r <= qr) {
    setmult(o, l, r, x, y);
    return;
  }
  pushdown(o, l, r);
  int mid = (l + r) >> 1;
  if (mid >= ql) mult(o << 1, l, mid, ql, qr, x, y);
  if (mid < qr) mult(o << 1 | 1, mid + 1, r, ql, qr, x, y);
  pushup(nd[o], nd[o << 1], nd[o << 1 | 1]);
}
node query(int o, int l, int r, int ql, int qr) {
  if (l >= ql && r <= qr) return nd[o];
  pushdown(o, l, r);
  int mid = (l + r) >> 1;
  if (mid < ql) return query(o << 1 | 1, mid + 1, r, ql, qr);
  if (mid >= qr) return query(o << 1, l, mid, ql, qr);
  node ans;
  pushup(ans, query(o << 1, l, mid, ql, qr),
         query(o << 1 | 1, mid + 1, r, ql, qr));
  return ans;
}
int main() {
  init();
  n = read();
  q = read();
  for (int i = (1); i <= (n); i++) a[i] = read();
  build(1, 1, n);
  for (int i = (1); i <= (q); i++) {
    char op[11];
    scanf("%s", op);
    int l = read(), r = read();
    if (op[0] == 'M') {
      int x = read();
      long long y = 0;
      for (int i = (1); i <= (pl); i++)
        if (x % pri[i] == 0) y |= 1ll << (i - 1);
      mult(1, 1, n, l, r, x, y);
    } else {
      node ans = query(1, 1, n, l, r);
      int s = ans.pro;
      for (int i = (1); i <= (pl); i++)
        if (ans.has & (1ll << (i - 1))) s = 1ll * s * f[i] % mod;
      printf("%d\n", s);
    }
  }
  return 0;
}

### Prompt

Please formulate 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;
const int inf = 0x3f3f3f3f;
const int maxn = 400040, mod = 1000000007;
inline int read() {
  char ch = getchar();
  int x = 0, f = 0;
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
int n, q, pri[66], pl, a[maxn], inv[333], f[66], tag1[maxn * 4];
long long tag2[maxn * 4];
bool vis[333];
void init() {
  for (int i = (2); i <= (300); i++) {
    if (!vis[i]) pri[++pl] = i;
    for (int j = 1; j <= pl && i * pri[j] <= 300; j++) {
      vis[i * pri[j]] = true;
      if (i % pri[j] == 0) break;
    }
  }
  inv[1] = 1;
  for (int i = (2); i <= (300); i++)
    inv[i] = mod - 1ll * (mod / i) * inv[mod % i] % mod;
  for (int i = (1); i <= (pl); i++)
    f[i] = 1ll * inv[pri[i]] * (pri[i] - 1) % mod;
}
inline int qpow(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) ans = 1ll * ans * a % mod;
  return ans;
}
struct node {
  int pro;
  long long has;
} nd[maxn * 4];
void pushup(node &o, node l, node r) {
  o.has = l.has | r.has;
  o.pro = 1ll * l.pro * r.pro % mod;
}
void setmult(int o, int l, int r, int x, long long y) {
  tag1[o] = 1ll * tag1[o] * x % mod;
  tag2[o] |= y;
  nd[o].pro = 1ll * nd[o].pro * qpow(x, r - l + 1) % mod;
  nd[o].has |= y;
}
void pushdown(int o, int l, int r) {
  if (!tag2[o]) return;
  int mid = (l + r) >> 1;
  setmult(o << 1, l, mid, tag1[o], tag2[o]);
  setmult(o << 1 | 1, mid + 1, r, tag1[o], tag2[o]);
  tag1[o] = 1;
  tag2[o] = 0;
}
void build(int o, int l, int r) {
  tag1[o] = 1;
  tag2[o] = 0;
  if (l == r) {
    nd[o].pro = a[l];
    for (int i = (1); i <= (pl); i++)
      if (a[l] % pri[i] == 0) nd[o].has |= 1ll << (i - 1);
    return;
  }
  int mid = (l + r) >> 1;
  build(o << 1, l, mid);
  build(o << 1 | 1, mid + 1, r);
  pushup(nd[o], nd[o << 1], nd[o << 1 | 1]);
}
void mult(int o, int l, int r, int ql, int qr, int x, long long y) {
  if (l >= ql && r <= qr) {
    setmult(o, l, r, x, y);
    return;
  }
  pushdown(o, l, r);
  int mid = (l + r) >> 1;
  if (mid >= ql) mult(o << 1, l, mid, ql, qr, x, y);
  if (mid < qr) mult(o << 1 | 1, mid + 1, r, ql, qr, x, y);
  pushup(nd[o], nd[o << 1], nd[o << 1 | 1]);
}
node query(int o, int l, int r, int ql, int qr) {
  if (l >= ql && r <= qr) return nd[o];
  pushdown(o, l, r);
  int mid = (l + r) >> 1;
  if (mid < ql) return query(o << 1 | 1, mid + 1, r, ql, qr);
  if (mid >= qr) return query(o << 1, l, mid, ql, qr);
  node ans;
  pushup(ans, query(o << 1, l, mid, ql, qr),
         query(o << 1 | 1, mid + 1, r, ql, qr));
  return ans;
}
int main() {
  init();
  n = read();
  q = read();
  for (int i = (1); i <= (n); i++) a[i] = read();
  build(1, 1, n);
  for (int i = (1); i <= (q); i++) {
    char op[11];
    scanf("%s", op);
    int l = read(), r = read();
    if (op[0] == 'M') {
      int x = read();
      long long y = 0;
      for (int i = (1); i <= (pl); i++)
        if (x % pri[i] == 0) y |= 1ll << (i - 1);
      mult(1, 1, n, l, r, x, y);
    } else {
      node ans = query(1, 1, n, l, r);
      int s = ans.pro;
      for (int i = (1); i <= (pl); i++)
        if (ans.has & (1ll << (i - 1))) s = 1ll * s * f[i] % mod;
      printf("%d\n", s);
    }
  }
  return 0;
}

```