#include <bits/stdc++.h>
using namespace std;
const int MAXN = 400100;
const int MOD = 1e9 + 7;
int mult(int a, int b) {
  long long c = (long long)a * b;
  return c % MOD;
}
int add(int a, int b) {
  long long c = (long long)a + b;
  while (c < 0) c += MOD;
  return c % MOD;
}
int fast_pow(int a, long long b) {
  if (a == 1 || a == 0) return a;
  if (b == 0) return 1;
  if (b == 1) return a;
  int c = fast_pow(a, b / 2);
  c = mult(c, c);
  if (b & 1) c = mult(c, a);
  return c;
}
int t[2 * MAXN], d[MAXN];
long long t1[2 * MAXN];
long long d1[MAXN];
int n;
int h;
vector<int> primes;
void calc(int p, int k) {
  t[p] = mult(t[p << 1], t[p << 1 | 1]);
  t1[p] = t1[p << 1] | t1[p << 1 | 1];
  t[p] = mult(t[p], fast_pow(d[p], k));
  t1[p] |= d1[p];
}
long long toBitMask(int val) {
  long long ret = 0;
  for (int i = 0; i < (int)primes.size() && val > 1; i++) {
    int p = primes[i];
    while (val % p == 0) {
      ret |= 1LL << i;
      val /= p;
    }
  }
  return ret;
}
void apply(int p, int val, long long mask, int k) {
  t[p] = mult(t[p], fast_pow(val, k));
  t1[p] |= mask;
  if (p < n) {
    d[p] = mult(d[p], val);
    d1[p] |= mask;
  }
}
void build(int l, int r) {
  int k = 2;
  for (l += n, r += n - 1; l > 1; k <<= 1) {
    l >>= 1, r >>= 1;
    for (int i = r; i >= l; --i) calc(i, k);
  }
}
void push(int l, int r) {
  int s = h, k = 1 << (h - 1);
  for (l += n, r += n - 1; s > 0; --s, k >>= 1)
    for (int i = l >> s; i <= r >> s; i++)
      if (d[i] != 1) {
        apply(i << 1, d[i], d1[i], k);
        apply(i << 1 | 1, d[i], d1[i], k);
        d[i] = 1;
        d1[i] = 0;
      }
}
void modify(int l, int r, int val) {
  if (val == 1) return;
  int l0 = l, r0 = r, k = 1;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1, k <<= 1) {
    long long mask = toBitMask(val);
    if (l & 1) apply(l++, val, mask, k);
    if (r & 1) apply(--r, val, mask, k);
  }
  build(l0, l0 + 1);
  build(r0 - 1, r0);
}
vector<int> primesI;
int query(int l, int r) {
  push(l, l + 1);
  push(r - 1, r);
  int res = 1;
  long long mask = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) {
      mask |= t1[l];
      res = mult(res, t[l++]);
    }
    if (r & 1) {
      res = mult(res, t[--r]);
      mask |= t1[r];
    }
  }
  for (int i = 0; i < (int)primes.size(); i++) {
    if (mask & (1LL << i)) {
      res = mult(res, primesI[i]);
    }
  }
  return res;
}
int q;
void load() {
  scanf("%d%d", &n, &q);
  h = sizeof(int) * 8 - __builtin_clz(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", t + n + i);
  }
  for (int i = 0; i < n; i++) d[i] = 1;
  auto IS_PRIME = [](int p) -> bool {
    for (int i = 2; i * i <= p; i++)
      if (p % i == 0) return false;
    return true;
  };
  for (int i = 2; i < 300; i++) {
    if (IS_PRIME(i)) {
      primes.push_back(i);
      primesI.push_back(mult(i - 1, fast_pow(i, MOD - 2)));
    }
  }
  for (int i = 0; i < n; i++) t1[n + i] = toBitMask(t[n + i]);
  build(0, n);
}
char s[10];
void solve() {
  while (q--) {
    int b, c, v;
    scanf("%s", s);
    if (s[0] == 'M') {
      scanf("%d%d%d", &b, &c, &v);
      b--;
      modify(b, c, v);
    } else {
      scanf("%d%d", &b, &c);
      b--;
      printf("%d\n", query(b, c));
    }
  }
}
int main() {
  load();
  solve();
  return 0;
}

### Prompt

Please create a solution in Cpp 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 = 400100;
const int MOD = 1e9 + 7;
int mult(int a, int b) {
  long long c = (long long)a * b;
  return c % MOD;
}
int add(int a, int b) {
  long long c = (long long)a + b;
  while (c < 0) c += MOD;
  return c % MOD;
}
int fast_pow(int a, long long b) {
  if (a == 1 || a == 0) return a;
  if (b == 0) return 1;
  if (b == 1) return a;
  int c = fast_pow(a, b / 2);
  c = mult(c, c);
  if (b & 1) c = mult(c, a);
  return c;
}
int t[2 * MAXN], d[MAXN];
long long t1[2 * MAXN];
long long d1[MAXN];
int n;
int h;
vector<int> primes;
void calc(int p, int k) {
  t[p] = mult(t[p << 1], t[p << 1 | 1]);
  t1[p] = t1[p << 1] | t1[p << 1 | 1];
  t[p] = mult(t[p], fast_pow(d[p], k));
  t1[p] |= d1[p];
}
long long toBitMask(int val) {
  long long ret = 0;
  for (int i = 0; i < (int)primes.size() && val > 1; i++) {
    int p = primes[i];
    while (val % p == 0) {
      ret |= 1LL << i;
      val /= p;
    }
  }
  return ret;
}
void apply(int p, int val, long long mask, int k) {
  t[p] = mult(t[p], fast_pow(val, k));
  t1[p] |= mask;
  if (p < n) {
    d[p] = mult(d[p], val);
    d1[p] |= mask;
  }
}
void build(int l, int r) {
  int k = 2;
  for (l += n, r += n - 1; l > 1; k <<= 1) {
    l >>= 1, r >>= 1;
    for (int i = r; i >= l; --i) calc(i, k);
  }
}
void push(int l, int r) {
  int s = h, k = 1 << (h - 1);
  for (l += n, r += n - 1; s > 0; --s, k >>= 1)
    for (int i = l >> s; i <= r >> s; i++)
      if (d[i] != 1) {
        apply(i << 1, d[i], d1[i], k);
        apply(i << 1 | 1, d[i], d1[i], k);
        d[i] = 1;
        d1[i] = 0;
      }
}
void modify(int l, int r, int val) {
  if (val == 1) return;
  int l0 = l, r0 = r, k = 1;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1, k <<= 1) {
    long long mask = toBitMask(val);
    if (l & 1) apply(l++, val, mask, k);
    if (r & 1) apply(--r, val, mask, k);
  }
  build(l0, l0 + 1);
  build(r0 - 1, r0);
}
vector<int> primesI;
int query(int l, int r) {
  push(l, l + 1);
  push(r - 1, r);
  int res = 1;
  long long mask = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) {
      mask |= t1[l];
      res = mult(res, t[l++]);
    }
    if (r & 1) {
      res = mult(res, t[--r]);
      mask |= t1[r];
    }
  }
  for (int i = 0; i < (int)primes.size(); i++) {
    if (mask & (1LL << i)) {
      res = mult(res, primesI[i]);
    }
  }
  return res;
}
int q;
void load() {
  scanf("%d%d", &n, &q);
  h = sizeof(int) * 8 - __builtin_clz(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", t + n + i);
  }
  for (int i = 0; i < n; i++) d[i] = 1;
  auto IS_PRIME = [](int p) -> bool {
    for (int i = 2; i * i <= p; i++)
      if (p % i == 0) return false;
    return true;
  };
  for (int i = 2; i < 300; i++) {
    if (IS_PRIME(i)) {
      primes.push_back(i);
      primesI.push_back(mult(i - 1, fast_pow(i, MOD - 2)));
    }
  }
  for (int i = 0; i < n; i++) t1[n + i] = toBitMask(t[n + i]);
  build(0, n);
}
char s[10];
void solve() {
  while (q--) {
    int b, c, v;
    scanf("%s", s);
    if (s[0] == 'M') {
      scanf("%d%d%d", &b, &c, &v);
      b--;
      modify(b, c, v);
    } else {
      scanf("%d%d", &b, &c);
      b--;
      printf("%d\n", query(b, c));
    }
  }
}
int main() {
  load();
  solve();
  return 0;
}

```