#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 10;
const int mod = 1e9 + 7;
int n, q, sz;
int a[maxn], prime[100], vis[400], pos[400];
void init() {
  int m = sqrt(300);
  for (int i = 2; i <= m; i++) {
    if (!vis[i]) {
      for (int j = i * i; j <= 300; j += i) {
        vis[j] = 1;
      }
    }
  }
  for (int i = 2; i <= 300; i++) {
    if (!vis[i]) {
      prime[sz] = i;
      pos[i] = sz++;
    }
  }
}
long long qpow(int n, int k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = res * n % mod;
    n = (long long)n * n % mod;
    k >>= 1;
  }
  return res % mod;
}
long long mulv[4 * maxn], prmv[4 * maxn];
long long tag_m[4 * maxn], tag_p[4 * maxn];
long long solve(int x) {
  long long res = 0;
  int m = sqrt(x);
  for (int i = 2; i <= m; i++) {
    if (x % i == 0) {
      res |= (long long)(1ll << pos[i]);
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) {
    res |= (long long)(1ll << pos[x]);
  }
  return res;
}
void maintain(int o) {
  int lc = 2 * o, rc = 2 * o + 1;
  mulv[o] = mulv[lc] * mulv[rc] % mod;
  prmv[o] = prmv[lc] | prmv[rc];
}
void pushdown(int o, int L, int R) {
  int lc = 2 * o, rc = 2 * o + 1;
  if (tag_m[o] != 1) {
    int M = L + (R - L) / 2;
    mulv[lc] = qpow(tag_m[o], M - L + 1) * mulv[lc] % mod;
    mulv[rc] = qpow(tag_m[o], R - M) * mulv[rc] % mod;
    tag_m[lc] = tag_m[o] * tag_m[lc] % mod;
    tag_m[rc] = tag_m[o] * tag_m[rc] % mod;
    tag_m[o] = 1;
  }
  if (tag_p[o]) {
    prmv[lc] |= tag_p[o];
    prmv[rc] |= tag_p[o];
    tag_p[lc] |= tag_p[o];
    tag_p[rc] |= tag_p[o];
    tag_p[o] = 0;
  }
}
void build(int o, int L, int R) {
  mulv[o] = tag_m[o] = 1;
  prmv[o] = tag_p[o] = 0;
  if (L == R) {
    mulv[o] = a[L];
    prmv[o] = solve(a[L]);
    return;
  }
  int M = L + (R - L) / 2;
  build(2 * o, L, M);
  build(2 * o + 1, M + 1, R);
  maintain(o);
}
void update(int o, int L, int R, int ql, int qr, int v) {
  if (ql <= L && qr >= R) {
    mulv[o] = mulv[o] * qpow(v, R - L + 1) % mod;
    tag_m[o] = tag_m[o] * v % mod;
    long long S = solve(v);
    tag_p[o] |= S;
    prmv[o] |= S;
    return;
  }
  int M = L + (R - L) / 2;
  pushdown(o, L, R);
  if (ql <= M) update(2 * o, L, M, ql, qr, v);
  if (qr > M) update(2 * o + 1, M + 1, R, ql, qr, v);
  maintain(o);
}
long long ans_S, ans;
void query(int o, int L, int R, int ql, int qr) {
  if (ql <= L && qr >= R) {
    ans = ans * mulv[o] % mod;
    ans_S |= prmv[o];
    return;
  }
  int M = L + (R - L) / 2;
  pushdown(o, L, R);
  if (ql <= M) query(2 * o, L, M, ql, qr);
  if (qr > M) query(2 * o + 1, M + 1, R, ql, qr);
  maintain(o);
}
void gcd(long long a, long long b, long long& d, long long& x, long long& y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    gcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
long long inv(long long a, long long p) {
  long long d, x, y;
  gcd(a, p, d, x, y);
  if (d != 1) return -1;
  return (x + p) % p;
}
void tra(int o, int L, int R) {
  printf("%d %d %d %I64d %I64d\n", o, L, R, mulv[o], prmv[o]);
  if (L == R) return;
  int M = L + (R - L) / 2;
  tra(2 * o, L, M);
  tra(2 * o + 1, M + 1, R);
}
int main() {
  init();
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    string type;
    cin >> type;
    if (type == "TOTIENT") {
      int ql, qr;
      scanf("%d%d", &ql, &qr);
      ans = 1, ans_S = 0;
      query(1, 1, n, ql, qr);
      long long sum = 1;
      for (int j = 0; j < 62; j++) {
        long long S = (long long)(1ll << j);
        if (ans_S & S) {
          sum = sum * (prime[j] - 1) % mod * inv(prime[j], mod) % mod;
        }
      }
      long long ANS = sum * ans % mod;
      printf("%I64d\n", ANS);
    } else {
      int ql, qr, v;
      scanf("%d%d%d", &ql, &qr, &v);
      update(1, 1, n, ql, qr, v);
    }
  }
  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 maxn = 4e5 + 10;
const int mod = 1e9 + 7;
int n, q, sz;
int a[maxn], prime[100], vis[400], pos[400];
void init() {
  int m = sqrt(300);
  for (int i = 2; i <= m; i++) {
    if (!vis[i]) {
      for (int j = i * i; j <= 300; j += i) {
        vis[j] = 1;
      }
    }
  }
  for (int i = 2; i <= 300; i++) {
    if (!vis[i]) {
      prime[sz] = i;
      pos[i] = sz++;
    }
  }
}
long long qpow(int n, int k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = res * n % mod;
    n = (long long)n * n % mod;
    k >>= 1;
  }
  return res % mod;
}
long long mulv[4 * maxn], prmv[4 * maxn];
long long tag_m[4 * maxn], tag_p[4 * maxn];
long long solve(int x) {
  long long res = 0;
  int m = sqrt(x);
  for (int i = 2; i <= m; i++) {
    if (x % i == 0) {
      res |= (long long)(1ll << pos[i]);
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) {
    res |= (long long)(1ll << pos[x]);
  }
  return res;
}
void maintain(int o) {
  int lc = 2 * o, rc = 2 * o + 1;
  mulv[o] = mulv[lc] * mulv[rc] % mod;
  prmv[o] = prmv[lc] | prmv[rc];
}
void pushdown(int o, int L, int R) {
  int lc = 2 * o, rc = 2 * o + 1;
  if (tag_m[o] != 1) {
    int M = L + (R - L) / 2;
    mulv[lc] = qpow(tag_m[o], M - L + 1) * mulv[lc] % mod;
    mulv[rc] = qpow(tag_m[o], R - M) * mulv[rc] % mod;
    tag_m[lc] = tag_m[o] * tag_m[lc] % mod;
    tag_m[rc] = tag_m[o] * tag_m[rc] % mod;
    tag_m[o] = 1;
  }
  if (tag_p[o]) {
    prmv[lc] |= tag_p[o];
    prmv[rc] |= tag_p[o];
    tag_p[lc] |= tag_p[o];
    tag_p[rc] |= tag_p[o];
    tag_p[o] = 0;
  }
}
void build(int o, int L, int R) {
  mulv[o] = tag_m[o] = 1;
  prmv[o] = tag_p[o] = 0;
  if (L == R) {
    mulv[o] = a[L];
    prmv[o] = solve(a[L]);
    return;
  }
  int M = L + (R - L) / 2;
  build(2 * o, L, M);
  build(2 * o + 1, M + 1, R);
  maintain(o);
}
void update(int o, int L, int R, int ql, int qr, int v) {
  if (ql <= L && qr >= R) {
    mulv[o] = mulv[o] * qpow(v, R - L + 1) % mod;
    tag_m[o] = tag_m[o] * v % mod;
    long long S = solve(v);
    tag_p[o] |= S;
    prmv[o] |= S;
    return;
  }
  int M = L + (R - L) / 2;
  pushdown(o, L, R);
  if (ql <= M) update(2 * o, L, M, ql, qr, v);
  if (qr > M) update(2 * o + 1, M + 1, R, ql, qr, v);
  maintain(o);
}
long long ans_S, ans;
void query(int o, int L, int R, int ql, int qr) {
  if (ql <= L && qr >= R) {
    ans = ans * mulv[o] % mod;
    ans_S |= prmv[o];
    return;
  }
  int M = L + (R - L) / 2;
  pushdown(o, L, R);
  if (ql <= M) query(2 * o, L, M, ql, qr);
  if (qr > M) query(2 * o + 1, M + 1, R, ql, qr);
  maintain(o);
}
void gcd(long long a, long long b, long long& d, long long& x, long long& y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    gcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
long long inv(long long a, long long p) {
  long long d, x, y;
  gcd(a, p, d, x, y);
  if (d != 1) return -1;
  return (x + p) % p;
}
void tra(int o, int L, int R) {
  printf("%d %d %d %I64d %I64d\n", o, L, R, mulv[o], prmv[o]);
  if (L == R) return;
  int M = L + (R - L) / 2;
  tra(2 * o, L, M);
  tra(2 * o + 1, M + 1, R);
}
int main() {
  init();
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    string type;
    cin >> type;
    if (type == "TOTIENT") {
      int ql, qr;
      scanf("%d%d", &ql, &qr);
      ans = 1, ans_S = 0;
      query(1, 1, n, ql, qr);
      long long sum = 1;
      for (int j = 0; j < 62; j++) {
        long long S = (long long)(1ll << j);
        if (ans_S & S) {
          sum = sum * (prime[j] - 1) % mod * inv(prime[j], mod) % mod;
        }
      }
      long long ANS = sum * ans % mod;
      printf("%I64d\n", ANS);
    } else {
      int ql, qr, v;
      scanf("%d%d%d", &ql, &qr, &v);
      update(1, 1, n, ql, qr, v);
    }
  }
  return 0;
}

```