#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
const int M = 1e9 + 7;
int pa[N << 2], lpa[N << 2];
int a[N];
long long oa[N << 2], loa[N << 2];
int invprime[70];
int prime[] = {2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,
               43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101,
               103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
               173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,
               241, 251, 257, 263, 269, 271, 277, 281, 283, 293};
long long power(long long x, long long y) {
  x %= M;
  long long ans = 1;
  while (y) {
    if (y & 1) ans = (ans * x) % M;
    y >>= 1;
    x = (x * x) % M;
  }
  return (ans % M);
}
long long divi(long long a, long long b) { return ((a * power(b, M - 2)) % M); }
void pprop(int node, int st, int end) {
  if (lpa[node] == 1) return;
  pa[node] = (1LL * pa[node] * power(lpa[node], (end - st + 1))) % M;
  if (st != end) {
    lpa[node << 1] = (1LL * lpa[node << 1] * lpa[node]) % M;
    lpa[(node << 1) | 1] = (1LL * lpa[(node << 1) | 1] * lpa[node]) % M;
  }
  lpa[node] = 1;
}
void pup(int node, int st, int end, int l, int r, int val) {
  pprop(node, st, end);
  if (st > end || r < st || l > end) return;
  if (l <= st && end <= r) {
    lpa[node] = (1LL * lpa[node] * val) % M;
    pprop(node, st, end);
    return;
  }
  int mid = st + end >> 1;
  pup(node << 1, st, mid, l, r, val);
  pup((node << 1) | 1, mid + 1, end, l, r, val);
  pa[node] = (1LL * pa[node << 1] * pa[(node << 1) | 1]) % M;
}
int pquery(int node, int st, int end, int l, int r) {
  pprop(node, st, end);
  if (st > end || r < st || l > end) return 1;
  if (l <= st && end <= r) return pa[node];
  int mid = st + end >> 1;
  return ((1LL * pquery(node << 1, st, mid, l, r) *
           pquery((node << 1) | 1, mid + 1, end, l, r)) %
          M);
}
void oprop(int node, int st, int end) {
  if (loa[node] == 0) return;
  oa[node] |= loa[node];
  if (st != end) {
    loa[node << 1] |= loa[node];
    loa[(node << 1) | 1] |= loa[node];
  }
  loa[node] = 0;
}
void oup(int node, int st, int end, int l, int r, long long val) {
  oprop(node, st, end);
  if (st > end || r < st || l > end) return;
  if (l <= st && end <= r) {
    loa[node] |= val;
    oprop(node, st, end);
    return;
  }
  int mid = st + end >> 1;
  oup(node << 1, st, mid, l, r, val);
  oup((node << 1) | 1, mid + 1, end, l, r, val);
  oa[node] = oa[node << 1] | oa[(node << 1) | 1];
}
long long oquery(int node, int st, int end, int l, int r) {
  oprop(node, st, end);
  if (st > end || r < st || l > end) return 0;
  if (l <= st && end <= r) return oa[node];
  int mid = st + end >> 1;
  return (oquery(node << 1, st, mid, l, r) |
          oquery((node << 1) | 1, mid + 1, end, l, r));
}
vector<long long> mask(320, 0);
void pre() {
  for (int i = 0; i < (N << 2); i++) pa[i] = 1, lpa[i] = 1;
  for (int i = 1; i <= 300; i++) {
    for (int j = 0; j < 62; j++) {
      if (i % prime[j] == 0) mask[i] |= (1LL << j);
    }
  }
  for (int i = 0; i < 62; i++) {
    invprime[i] = power(prime[i], M - 2);
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  pre();
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pup(1, 1, n, i, i, a[i]);
    oup(1, 1, n, i, i, mask[a[i]]);
  }
  string yo;
  int l, r;
  int x;
  while (q--) {
    cin >> yo >> l >> r;
    if (yo == "MULTIPLY") {
      cin >> x;
      pup(1, 1, n, l, r, x);
      oup(1, 1, n, l, r, mask[x]);
    } else {
      int ans = pquery(1, 1, n, l, r);
      long long smask = oquery(1, 1, n, l, r);
      for (int i = 0; i < 62; i++) {
        if ((1LL << i) & smask) {
          ans = (1LL * ans * (prime[i] - 1)) % M;
          ans = (1LL * ans * invprime[i]) % M;
        }
      }
      cout << ans << "\n";
    }
  }
  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 int N = 4e5 + 5;
const int M = 1e9 + 7;
int pa[N << 2], lpa[N << 2];
int a[N];
long long oa[N << 2], loa[N << 2];
int invprime[70];
int prime[] = {2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,
               43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101,
               103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
               173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,
               241, 251, 257, 263, 269, 271, 277, 281, 283, 293};
long long power(long long x, long long y) {
  x %= M;
  long long ans = 1;
  while (y) {
    if (y & 1) ans = (ans * x) % M;
    y >>= 1;
    x = (x * x) % M;
  }
  return (ans % M);
}
long long divi(long long a, long long b) { return ((a * power(b, M - 2)) % M); }
void pprop(int node, int st, int end) {
  if (lpa[node] == 1) return;
  pa[node] = (1LL * pa[node] * power(lpa[node], (end - st + 1))) % M;
  if (st != end) {
    lpa[node << 1] = (1LL * lpa[node << 1] * lpa[node]) % M;
    lpa[(node << 1) | 1] = (1LL * lpa[(node << 1) | 1] * lpa[node]) % M;
  }
  lpa[node] = 1;
}
void pup(int node, int st, int end, int l, int r, int val) {
  pprop(node, st, end);
  if (st > end || r < st || l > end) return;
  if (l <= st && end <= r) {
    lpa[node] = (1LL * lpa[node] * val) % M;
    pprop(node, st, end);
    return;
  }
  int mid = st + end >> 1;
  pup(node << 1, st, mid, l, r, val);
  pup((node << 1) | 1, mid + 1, end, l, r, val);
  pa[node] = (1LL * pa[node << 1] * pa[(node << 1) | 1]) % M;
}
int pquery(int node, int st, int end, int l, int r) {
  pprop(node, st, end);
  if (st > end || r < st || l > end) return 1;
  if (l <= st && end <= r) return pa[node];
  int mid = st + end >> 1;
  return ((1LL * pquery(node << 1, st, mid, l, r) *
           pquery((node << 1) | 1, mid + 1, end, l, r)) %
          M);
}
void oprop(int node, int st, int end) {
  if (loa[node] == 0) return;
  oa[node] |= loa[node];
  if (st != end) {
    loa[node << 1] |= loa[node];
    loa[(node << 1) | 1] |= loa[node];
  }
  loa[node] = 0;
}
void oup(int node, int st, int end, int l, int r, long long val) {
  oprop(node, st, end);
  if (st > end || r < st || l > end) return;
  if (l <= st && end <= r) {
    loa[node] |= val;
    oprop(node, st, end);
    return;
  }
  int mid = st + end >> 1;
  oup(node << 1, st, mid, l, r, val);
  oup((node << 1) | 1, mid + 1, end, l, r, val);
  oa[node] = oa[node << 1] | oa[(node << 1) | 1];
}
long long oquery(int node, int st, int end, int l, int r) {
  oprop(node, st, end);
  if (st > end || r < st || l > end) return 0;
  if (l <= st && end <= r) return oa[node];
  int mid = st + end >> 1;
  return (oquery(node << 1, st, mid, l, r) |
          oquery((node << 1) | 1, mid + 1, end, l, r));
}
vector<long long> mask(320, 0);
void pre() {
  for (int i = 0; i < (N << 2); i++) pa[i] = 1, lpa[i] = 1;
  for (int i = 1; i <= 300; i++) {
    for (int j = 0; j < 62; j++) {
      if (i % prime[j] == 0) mask[i] |= (1LL << j);
    }
  }
  for (int i = 0; i < 62; i++) {
    invprime[i] = power(prime[i], M - 2);
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  pre();
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pup(1, 1, n, i, i, a[i]);
    oup(1, 1, n, i, i, mask[a[i]]);
  }
  string yo;
  int l, r;
  int x;
  while (q--) {
    cin >> yo >> l >> r;
    if (yo == "MULTIPLY") {
      cin >> x;
      pup(1, 1, n, l, r, x);
      oup(1, 1, n, l, r, mask[x]);
    } else {
      int ans = pquery(1, 1, n, l, r);
      long long smask = oquery(1, 1, n, l, r);
      for (int i = 0; i < 62; i++) {
        if ((1LL << i) & smask) {
          ans = (1LL * ans * (prime[i] - 1)) % M;
          ans = (1LL * ans * invprime[i]) % M;
        }
      }
      cout << ans << "\n";
    }
  }
  return 0;
}

```