#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
const long long MAXN = 4e5 + 5;
const long long MAXA = 300;
const long long MOD = 1e9 + 7;
long long n, tot, q;
long long a[MAXN], p[MAXA + 5], inv[MAXA + 5];
bool v[MAXA + 5];
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return res;
}
void getPrime() {
  for (long long i = 2; i <= MAXA; i++) {
    if (!v[i]) p[++tot] = i;
    for (long long j = 1; j <= tot; j++) {
      if (i * p[j] > MAXA) break;
      v[i * p[j]] = true;
      if (i % p[j] == 0) break;
    }
  }
  for (long long i = 1; i <= tot; i++) inv[i] = power(p[i], MOD - 2);
}
long long getBin(long long x) {
  long long res = 0;
  for (long long i = 1; i <= tot; i++) {
    if (x % p[i] == 0) res |= (1ll << (i - 1));
  }
  return res;
}
struct SegTree {
  struct Tree {
    long long l, r;
    long long val, bin, tag1, tag2;
    Tree() {
      val = tag1 = 1;
      bin = tag2 = 0;
    }
  } t[MAXN << 2];
  void update(long long k) {
    t[k].val = t[k << 1].val * t[k << 1 | 1].val % MOD;
    t[k].bin = t[k << 1].bin | t[k << 1 | 1].bin;
  }
  void change(long long k, long long val, long long bin) {
    t[k].val = t[k].val * power(val, t[k].r - t[k].l + 1) % MOD;
    t[k].tag1 = t[k].tag1 * val % MOD;
    t[k].bin |= bin;
    t[k].tag2 |= bin;
  }
  void down(long long k) {
    if (t[k].tag2 == 0) return;
    change(k << 1, t[k].tag1, t[k].tag2);
    change(k << 1 | 1, t[k].tag1, t[k].tag2);
    t[k].tag1 = 1;
    t[k].tag2 = 0;
  }
  void build(long long k, long long l, long long r) {
    t[k].l = l;
    t[k].r = r;
    t[k].tag1 = 1;
    t[k].tag2 = 0;
    if (l == r) {
      t[k].val = a[l];
      t[k].bin = getBin(a[l]);
      return;
    }
    long long mid = (l + r) >> 1;
    build(k << 1, l, mid);
    build(k << 1 | 1, mid + 1, r);
    update(k);
  }
  void modify(long long k, long long l, long long r, long long val,
              long long bin) {
    if (t[k].l >= l && t[k].r <= r) {
      change(k, val, bin);
      return;
    }
    down(k);
    long long mid = (t[k].l + t[k].r) >> 1;
    if (l <= mid) modify(k << 1, l, r, val, bin);
    if (r > mid) modify(k << 1 | 1, l, r, val, bin);
    update(k);
  }
  long long queryVal(long long k, long long l, long long r) {
    if (t[k].l >= l && t[k].r <= r) return t[k].val;
    down(k);
    long long mid = (t[k].l + t[k].r) >> 1;
    long long res = 1;
    if (l <= mid) res = res * queryVal(k << 1, l, r) % MOD;
    if (r > mid) res = res * queryVal(k << 1 | 1, l, r) % MOD;
    return res;
  }
  long long queryBin(long long k, long long l, long long r) {
    if (t[k].l >= l && t[k].r <= r) return t[k].bin;
    down(k);
    long long mid = (t[k].l + t[k].r) >> 1;
    long long res = 0;
    if (l <= mid) res |= queryBin(k << 1, l, r);
    if (r > mid) res |= queryBin(k << 1 | 1, l, r);
    return res;
  }
} tree;
signed main() {
  getPrime();
  scanf("%lld%lld", &n, &q);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  tree.build(1, 1, n);
  while (q--) {
    char s[10];
    long long l, r, x, ans, bin;
    scanf("%s", s);
    if (s[0] == 'M') {
      scanf("%lld%lld%lld", &l, &r, &x);
      tree.modify(1, l, r, x, getBin(x));
    } else if (s[0] == 'T') {
      scanf("%lld%lld", &l, &r);
      ans = tree.queryVal(1, l, r);
      bin = tree.queryBin(1, l, r);
      for (long long i = 1; i <= tot; i++) {
        if ((bin >> (i - 1)) & 1ll) ans = ans * (p[i] - 1) % MOD * inv[i] % MOD;
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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 long long INF = 0x3f3f3f3f;
const long long MAXN = 4e5 + 5;
const long long MAXA = 300;
const long long MOD = 1e9 + 7;
long long n, tot, q;
long long a[MAXN], p[MAXA + 5], inv[MAXA + 5];
bool v[MAXA + 5];
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return res;
}
void getPrime() {
  for (long long i = 2; i <= MAXA; i++) {
    if (!v[i]) p[++tot] = i;
    for (long long j = 1; j <= tot; j++) {
      if (i * p[j] > MAXA) break;
      v[i * p[j]] = true;
      if (i % p[j] == 0) break;
    }
  }
  for (long long i = 1; i <= tot; i++) inv[i] = power(p[i], MOD - 2);
}
long long getBin(long long x) {
  long long res = 0;
  for (long long i = 1; i <= tot; i++) {
    if (x % p[i] == 0) res |= (1ll << (i - 1));
  }
  return res;
}
struct SegTree {
  struct Tree {
    long long l, r;
    long long val, bin, tag1, tag2;
    Tree() {
      val = tag1 = 1;
      bin = tag2 = 0;
    }
  } t[MAXN << 2];
  void update(long long k) {
    t[k].val = t[k << 1].val * t[k << 1 | 1].val % MOD;
    t[k].bin = t[k << 1].bin | t[k << 1 | 1].bin;
  }
  void change(long long k, long long val, long long bin) {
    t[k].val = t[k].val * power(val, t[k].r - t[k].l + 1) % MOD;
    t[k].tag1 = t[k].tag1 * val % MOD;
    t[k].bin |= bin;
    t[k].tag2 |= bin;
  }
  void down(long long k) {
    if (t[k].tag2 == 0) return;
    change(k << 1, t[k].tag1, t[k].tag2);
    change(k << 1 | 1, t[k].tag1, t[k].tag2);
    t[k].tag1 = 1;
    t[k].tag2 = 0;
  }
  void build(long long k, long long l, long long r) {
    t[k].l = l;
    t[k].r = r;
    t[k].tag1 = 1;
    t[k].tag2 = 0;
    if (l == r) {
      t[k].val = a[l];
      t[k].bin = getBin(a[l]);
      return;
    }
    long long mid = (l + r) >> 1;
    build(k << 1, l, mid);
    build(k << 1 | 1, mid + 1, r);
    update(k);
  }
  void modify(long long k, long long l, long long r, long long val,
              long long bin) {
    if (t[k].l >= l && t[k].r <= r) {
      change(k, val, bin);
      return;
    }
    down(k);
    long long mid = (t[k].l + t[k].r) >> 1;
    if (l <= mid) modify(k << 1, l, r, val, bin);
    if (r > mid) modify(k << 1 | 1, l, r, val, bin);
    update(k);
  }
  long long queryVal(long long k, long long l, long long r) {
    if (t[k].l >= l && t[k].r <= r) return t[k].val;
    down(k);
    long long mid = (t[k].l + t[k].r) >> 1;
    long long res = 1;
    if (l <= mid) res = res * queryVal(k << 1, l, r) % MOD;
    if (r > mid) res = res * queryVal(k << 1 | 1, l, r) % MOD;
    return res;
  }
  long long queryBin(long long k, long long l, long long r) {
    if (t[k].l >= l && t[k].r <= r) return t[k].bin;
    down(k);
    long long mid = (t[k].l + t[k].r) >> 1;
    long long res = 0;
    if (l <= mid) res |= queryBin(k << 1, l, r);
    if (r > mid) res |= queryBin(k << 1 | 1, l, r);
    return res;
  }
} tree;
signed main() {
  getPrime();
  scanf("%lld%lld", &n, &q);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  tree.build(1, 1, n);
  while (q--) {
    char s[10];
    long long l, r, x, ans, bin;
    scanf("%s", s);
    if (s[0] == 'M') {
      scanf("%lld%lld%lld", &l, &r, &x);
      tree.modify(1, l, r, x, getBin(x));
    } else if (s[0] == 'T') {
      scanf("%lld%lld", &l, &r);
      ans = tree.queryVal(1, l, r);
      bin = tree.queryBin(1, l, r);
      for (long long i = 1; i <= tot; i++) {
        if ((bin >> (i - 1)) & 1ll) ans = ans * (p[i] - 1) % MOD * inv[i] % MOD;
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}

```