#include <bits/stdc++.h>
using namespace std;
const long long N = 4e5 + 9, mod = 1e9 + 7;
inline long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - 48, c = getchar();
  }
  return x * f;
}
long long n, q, a[N], pr[N], inv[N], cnt;
bool vst[N];
long long ksm(long long a, long long b) {
  if (b == 0)
    return 1;
  else
    return ksm(a * a % mod, b / 2) * (b % 2 == 1 ? a : 1) % mod;
}
void sieve() {
  for (register long long i = (2); i <= (300); i++) {
    if (vst[i]) continue;
    pr[++cnt] = i, inv[cnt] = ksm(i, mod - 2);
    for (long long j = 2; i * j <= 300; j++) vst[i * j] = 1;
  }
}
struct node {
  long long l, r, s, tg1, tg2, prod;
} t[N * 4];
void build(long long p, long long l, long long r) {
  long long mid = ((t[p].l = l) + (t[p].r = r)) / 2;
  if (l == r) {
    for (register long long i = (1); i <= (cnt); i++)
      if (a[l] % pr[i] == 0) t[p].s += (1ll << i);
    t[p].prod = a[l];
    t[p].tg1 = 0, t[p].tg2 = 1;
    return;
  }
  build(p * 2, l, mid), build(p * 2 + 1, mid + 1, r);
  t[p].s = t[p * 2].s | t[p * 2 + 1].s,
  t[p].prod = t[p * 2].prod * t[p * 2 + 1].prod % mod;
  t[p].tg1 = 0, t[p].tg2 = 1;
}
void pushdown(long long p) {
  t[p * 2].s |= t[p].tg1, t[p * 2 + 1].s |= t[p].tg1;
  t[p * 2].tg1 |= t[p].tg1, t[p * 2 + 1].tg1 |= t[p].tg1;
  long long len = t[p * 2].r - t[p * 2].l + 1;
  t[p * 2].prod = (t[p * 2].prod * ksm(t[p].tg2, len)) % mod;
  t[p * 2].tg2 = (t[p * 2].tg2 * t[p].tg2) % mod;
  len = t[p * 2 + 1].r - t[p * 2 + 1].l + 1;
  t[p * 2 + 1].prod = (t[p * 2 + 1].prod * ksm(t[p].tg2, len)) % mod;
  t[p * 2 + 1].tg2 = (t[p * 2 + 1].tg2 * t[p].tg2) % mod;
  t[p].tg1 = 0, t[p].tg2 = 1;
}
void modify(long long p, long long x, long long y, long long g, long long k) {
  long long l = t[p].l, r = t[p].r, mid = (l + r) / 2;
  if (l == x && r == y) {
    t[p].s |= k, t[p].tg1 |= k;
    t[p].prod = t[p].prod * ksm(g, r - l + 1) % mod,
    t[p].tg2 = t[p].tg2 * g % mod;
    return;
  }
  pushdown(p);
  if (y <= mid)
    modify(p * 2, x, y, g, k);
  else if (x > mid)
    modify(p * 2 + 1, x, y, g, k);
  else
    modify(p * 2, x, mid, g, k), modify(p * 2 + 1, mid + 1, y, g, k);
  t[p].s = t[p * 2].s | t[p * 2 + 1].s,
  t[p].prod = t[p * 2].prod * t[p * 2 + 1].prod % mod;
}
pair<long long, long long> query(long long p, long long x, long long y) {
  long long l = t[p].l, r = t[p].r, mid = (l + r) / 2;
  if (l == x && r == y) return make_pair(t[p].s, t[p].prod);
  pushdown(p);
  if (y <= mid)
    return query(p * 2, x, y);
  else if (x > mid)
    return query(p * 2 + 1, x, y);
  else {
    pair<long long, long long> a = query(p * 2, x, mid),
                               b = query(p * 2 + 1, mid + 1, y);
    return make_pair(a.first | b.first, a.second * b.second % mod);
  }
}
signed main() {
  n = read(), q = read();
  sieve();
  for (register long long i = (1); i <= (n); i++) a[i] = read();
  build(1, 1, n);
  for (register long long i = (1); i <= (q); i++) {
    char opt[10];
    scanf("%s", opt);
    if (opt[0] == 'M') {
      long long l = read(), r = read(), x = read(), s = 0;
      for (register long long i = (1); i <= (cnt); i++)
        if (x % pr[i] == 0) s += (1ll << i);
      modify(1, l, r, x, s);
    } else {
      long long l = read(), r = read();
      pair<long long, long long> res = query(1, l, r);
      long long ans = res.second, s = res.first;
      for (register long long i = (1); i <= (cnt); i++)
        if (s & (1ll << i)) ans = (ans * inv[i] % mod * (pr[i] - 1) % mod);
      printf("%lld\n", ans);
    }
  }
  return 0;
}

### Prompt

Develop a solution in cpp 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 N = 4e5 + 9, mod = 1e9 + 7;
inline long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - 48, c = getchar();
  }
  return x * f;
}
long long n, q, a[N], pr[N], inv[N], cnt;
bool vst[N];
long long ksm(long long a, long long b) {
  if (b == 0)
    return 1;
  else
    return ksm(a * a % mod, b / 2) * (b % 2 == 1 ? a : 1) % mod;
}
void sieve() {
  for (register long long i = (2); i <= (300); i++) {
    if (vst[i]) continue;
    pr[++cnt] = i, inv[cnt] = ksm(i, mod - 2);
    for (long long j = 2; i * j <= 300; j++) vst[i * j] = 1;
  }
}
struct node {
  long long l, r, s, tg1, tg2, prod;
} t[N * 4];
void build(long long p, long long l, long long r) {
  long long mid = ((t[p].l = l) + (t[p].r = r)) / 2;
  if (l == r) {
    for (register long long i = (1); i <= (cnt); i++)
      if (a[l] % pr[i] == 0) t[p].s += (1ll << i);
    t[p].prod = a[l];
    t[p].tg1 = 0, t[p].tg2 = 1;
    return;
  }
  build(p * 2, l, mid), build(p * 2 + 1, mid + 1, r);
  t[p].s = t[p * 2].s | t[p * 2 + 1].s,
  t[p].prod = t[p * 2].prod * t[p * 2 + 1].prod % mod;
  t[p].tg1 = 0, t[p].tg2 = 1;
}
void pushdown(long long p) {
  t[p * 2].s |= t[p].tg1, t[p * 2 + 1].s |= t[p].tg1;
  t[p * 2].tg1 |= t[p].tg1, t[p * 2 + 1].tg1 |= t[p].tg1;
  long long len = t[p * 2].r - t[p * 2].l + 1;
  t[p * 2].prod = (t[p * 2].prod * ksm(t[p].tg2, len)) % mod;
  t[p * 2].tg2 = (t[p * 2].tg2 * t[p].tg2) % mod;
  len = t[p * 2 + 1].r - t[p * 2 + 1].l + 1;
  t[p * 2 + 1].prod = (t[p * 2 + 1].prod * ksm(t[p].tg2, len)) % mod;
  t[p * 2 + 1].tg2 = (t[p * 2 + 1].tg2 * t[p].tg2) % mod;
  t[p].tg1 = 0, t[p].tg2 = 1;
}
void modify(long long p, long long x, long long y, long long g, long long k) {
  long long l = t[p].l, r = t[p].r, mid = (l + r) / 2;
  if (l == x && r == y) {
    t[p].s |= k, t[p].tg1 |= k;
    t[p].prod = t[p].prod * ksm(g, r - l + 1) % mod,
    t[p].tg2 = t[p].tg2 * g % mod;
    return;
  }
  pushdown(p);
  if (y <= mid)
    modify(p * 2, x, y, g, k);
  else if (x > mid)
    modify(p * 2 + 1, x, y, g, k);
  else
    modify(p * 2, x, mid, g, k), modify(p * 2 + 1, mid + 1, y, g, k);
  t[p].s = t[p * 2].s | t[p * 2 + 1].s,
  t[p].prod = t[p * 2].prod * t[p * 2 + 1].prod % mod;
}
pair<long long, long long> query(long long p, long long x, long long y) {
  long long l = t[p].l, r = t[p].r, mid = (l + r) / 2;
  if (l == x && r == y) return make_pair(t[p].s, t[p].prod);
  pushdown(p);
  if (y <= mid)
    return query(p * 2, x, y);
  else if (x > mid)
    return query(p * 2 + 1, x, y);
  else {
    pair<long long, long long> a = query(p * 2, x, mid),
                               b = query(p * 2 + 1, mid + 1, y);
    return make_pair(a.first | b.first, a.second * b.second % mod);
  }
}
signed main() {
  n = read(), q = read();
  sieve();
  for (register long long i = (1); i <= (n); i++) a[i] = read();
  build(1, 1, n);
  for (register long long i = (1); i <= (q); i++) {
    char opt[10];
    scanf("%s", opt);
    if (opt[0] == 'M') {
      long long l = read(), r = read(), x = read(), s = 0;
      for (register long long i = (1); i <= (cnt); i++)
        if (x % pr[i] == 0) s += (1ll << i);
      modify(1, l, r, x, s);
    } else {
      long long l = read(), r = read();
      pair<long long, long long> res = query(1, l, r);
      long long ans = res.second, s = res.first;
      for (register long long i = (1); i <= (cnt); i++)
        if (s & (1ll << i)) ans = (ans * inv[i] % mod * (pr[i] - 1) % mod);
      printf("%lld\n", ans);
    }
  }
  return 0;
}

```