#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 400007;
long long num[maxn << 2], tagn[maxn << 2], pre[307][30007];
long long tag[maxn << 2];
long long sum[maxn << 2];
int id[67], e1, a[maxn];
void pushup(int o) {
  sum[o] = sum[o << 1] * sum[o << 1 | 1] % mod;
  num[o] = (num[o << 1] | num[o << 1 | 1]);
}
inline long long pown(long long a, long long b) {
  if (a <= 300 && b <= 30000) return pre[a][b];
  long long ans = 1;
  while (b) {
    if (b & 1) (ans *= a) %= mod;
    (a *= a) %= mod;
    b >>= 1;
  }
  return ans;
}
inline void pushdown(int o, int l, int r) {
  int m = (l + r) >> 1;
  if (tag[o] != 1) {
    long long x = pown(tag[o], m - l + 1);
    sum[o << 1] = sum[o << 1] * x % mod;
    sum[o << 1 | 1] =
        sum[o << 1 | 1] * (r - m == m - l + 1 ? x : pown(tag[o], r - m)) % mod;
    tag[o << 1] = tag[o << 1] * tag[o] % mod;
    tag[o << 1 | 1] = tag[o << 1 | 1] * tag[o] % mod;
    tagn[o << 1] |= tagn[o];
    tagn[o << 1 | 1] |= tagn[o];
    num[o << 1] |= tagn[o];
    num[o << 1 | 1] |= tagn[o];
    tag[o] = 1;
    tagn[o] = 0;
  }
}
inline void build(int o, int l, int r) {
  tag[o] = 1;
  if (l == r) {
    sum[o] = a[l];
    for (int i = 1; i <= e1; i++)
      if (a[l] % id[i] == 0) num[o] |= (1LL << i);
    return;
  }
  int m = (l + r) >> 1;
  build(o << 1, l, m);
  build(o << 1 | 1, m + 1, r);
  pushup(o);
}
inline void update(int o, int l, int r, int ql, int qr, int x) {
  if (l != r) pushdown(o, l, r);
  if (l == ql && r == qr) {
    tag[o] = tag[o] * id[x] % mod,
    sum[o] = sum[o] * pown(id[x], r - l + 1) % mod;
    num[o] |= (1LL << x);
    tagn[o] |= (1LL << x);
    return;
  }
  int m = (l + r) >> 1;
  if (ql <= m && qr > m)
    update(o << 1, l, m, ql, m, x), update(o << 1 | 1, m + 1, r, m + 1, qr, x);
  else if (ql <= m)
    update(o << 1, l, m, ql, qr, x);
  else
    update(o << 1 | 1, m + 1, r, ql, qr, x);
  pushup(o);
}
inline pair<long long, long long> query(int o, int l, int r, int ql, int qr) {
  if (l != r) pushdown(o, l, r);
  if (l == ql && r == qr) {
    return pair<long long, long long>(sum[o], num[o]);
  }
  int m = (l + r) >> 1;
  if (ql <= m && qr > m) {
    pair<long long, long long> q1 = query(o << 1, l, m, ql, m);
    pair<long long, long long> q2 = query(o << 1 | 1, m + 1, r, m + 1, qr);
    return make_pair(q1.first * q2.first % mod, q1.second | q2.second);
  } else if (ql <= m)
    return query(o << 1, l, m, ql, qr);
  else
    return query(o << 1 | 1, m + 1, r, ql, qr);
}
int vis[307];
int rea[307];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= 300; i++) {
    if (!vis[i]) {
      id[++e1] = i;
      for (int k = i * 2; k <= 300; k += i) vis[k] = 1;
    }
  }
  for (int i = 1; i <= 300; i++) {
    pre[i][0] = 1;
    for (int k = 1; k <= 30000; k++) pre[i][k] = pre[i][k - 1] * i % mod;
  }
  for (int i = 1; i <= e1; i++)
    rea[i] = (1LL * (id[i] - 1) * pown(id[i], mod - 2)) % mod;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  build(1, 1, n);
  for (int i = 1; i <= m; i++) {
    char s[17];
    scanf("%s", s + 1);
    int x, y;
    scanf("%d%d", &x, &y);
    if (s[1] == 'T') {
      pair<long long, long long> q = query(1, 1, n, x, y);
      for (int k = 1; k <= e1; k++) {
        if (q.second & (1LL << k)) {
          q.first = (1LL * q.first * rea[k]) % mod;
        }
      }
      printf("%d\n", q.first);
    } else {
      int z;
      scanf("%d", &z);
      for (int i = 1; i <= e1; i++) {
        while (z % id[i] == 0) {
          update(1, 1, n, x, y, i);
          z /= id[i];
        }
      }
    }
  }
  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 mod = 1e9 + 7;
const int maxn = 400007;
long long num[maxn << 2], tagn[maxn << 2], pre[307][30007];
long long tag[maxn << 2];
long long sum[maxn << 2];
int id[67], e1, a[maxn];
void pushup(int o) {
  sum[o] = sum[o << 1] * sum[o << 1 | 1] % mod;
  num[o] = (num[o << 1] | num[o << 1 | 1]);
}
inline long long pown(long long a, long long b) {
  if (a <= 300 && b <= 30000) return pre[a][b];
  long long ans = 1;
  while (b) {
    if (b & 1) (ans *= a) %= mod;
    (a *= a) %= mod;
    b >>= 1;
  }
  return ans;
}
inline void pushdown(int o, int l, int r) {
  int m = (l + r) >> 1;
  if (tag[o] != 1) {
    long long x = pown(tag[o], m - l + 1);
    sum[o << 1] = sum[o << 1] * x % mod;
    sum[o << 1 | 1] =
        sum[o << 1 | 1] * (r - m == m - l + 1 ? x : pown(tag[o], r - m)) % mod;
    tag[o << 1] = tag[o << 1] * tag[o] % mod;
    tag[o << 1 | 1] = tag[o << 1 | 1] * tag[o] % mod;
    tagn[o << 1] |= tagn[o];
    tagn[o << 1 | 1] |= tagn[o];
    num[o << 1] |= tagn[o];
    num[o << 1 | 1] |= tagn[o];
    tag[o] = 1;
    tagn[o] = 0;
  }
}
inline void build(int o, int l, int r) {
  tag[o] = 1;
  if (l == r) {
    sum[o] = a[l];
    for (int i = 1; i <= e1; i++)
      if (a[l] % id[i] == 0) num[o] |= (1LL << i);
    return;
  }
  int m = (l + r) >> 1;
  build(o << 1, l, m);
  build(o << 1 | 1, m + 1, r);
  pushup(o);
}
inline void update(int o, int l, int r, int ql, int qr, int x) {
  if (l != r) pushdown(o, l, r);
  if (l == ql && r == qr) {
    tag[o] = tag[o] * id[x] % mod,
    sum[o] = sum[o] * pown(id[x], r - l + 1) % mod;
    num[o] |= (1LL << x);
    tagn[o] |= (1LL << x);
    return;
  }
  int m = (l + r) >> 1;
  if (ql <= m && qr > m)
    update(o << 1, l, m, ql, m, x), update(o << 1 | 1, m + 1, r, m + 1, qr, x);
  else if (ql <= m)
    update(o << 1, l, m, ql, qr, x);
  else
    update(o << 1 | 1, m + 1, r, ql, qr, x);
  pushup(o);
}
inline pair<long long, long long> query(int o, int l, int r, int ql, int qr) {
  if (l != r) pushdown(o, l, r);
  if (l == ql && r == qr) {
    return pair<long long, long long>(sum[o], num[o]);
  }
  int m = (l + r) >> 1;
  if (ql <= m && qr > m) {
    pair<long long, long long> q1 = query(o << 1, l, m, ql, m);
    pair<long long, long long> q2 = query(o << 1 | 1, m + 1, r, m + 1, qr);
    return make_pair(q1.first * q2.first % mod, q1.second | q2.second);
  } else if (ql <= m)
    return query(o << 1, l, m, ql, qr);
  else
    return query(o << 1 | 1, m + 1, r, ql, qr);
}
int vis[307];
int rea[307];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= 300; i++) {
    if (!vis[i]) {
      id[++e1] = i;
      for (int k = i * 2; k <= 300; k += i) vis[k] = 1;
    }
  }
  for (int i = 1; i <= 300; i++) {
    pre[i][0] = 1;
    for (int k = 1; k <= 30000; k++) pre[i][k] = pre[i][k - 1] * i % mod;
  }
  for (int i = 1; i <= e1; i++)
    rea[i] = (1LL * (id[i] - 1) * pown(id[i], mod - 2)) % mod;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  build(1, 1, n);
  for (int i = 1; i <= m; i++) {
    char s[17];
    scanf("%s", s + 1);
    int x, y;
    scanf("%d%d", &x, &y);
    if (s[1] == 'T') {
      pair<long long, long long> q = query(1, 1, n, x, y);
      for (int k = 1; k <= e1; k++) {
        if (q.second & (1LL << k)) {
          q.first = (1LL * q.first * rea[k]) % mod;
        }
      }
      printf("%d\n", q.first);
    } else {
      int z;
      scanf("%d", &z);
      for (int i = 1; i <= e1; i++) {
        while (z % id[i] == 0) {
          update(1, 1, n, x, y, i);
          z /= id[i];
        }
      }
    }
  }
  return 0;
}

```