#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007LL;
char cmd[100];
int x, y, z;
const int N = 400005;
bool prime(int x) {
  for (int i = 2; i * i <= x; ++i)
    if (!(x % i)) return 0;
  return 1;
}
long long pow_mod(long long a, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) (ans *= a) %= mod;
    (a *= a) %= mod;
    n >>= 1;
  }
  return ans;
}
int n, q, p[66], cnt = 0;
long long inv[66], mul[N << 2], mask[N << 2], flag1[N << 2], flag2[N << 2];
void init(int r, int L, int R) {
  flag1[r] = 1;
  if (L == R) {
    scanf("%I64d", mul + r);
    for (int i = 0; i < cnt; ++i)
      if (!(mul[r] % p[i])) mask[r] |= (1LL << i);
    return;
  }
  int mid = L + R >> 1;
  init(r << 1, L, mid);
  init(r << 1 | 1, mid + 1, R);
  mul[r] = mul[r << 1] * mul[r << 1 | 1] % mod;
  mask[r] = mask[r << 1] | mask[r << 1 | 1];
}
long long getmask(int x) {
  long long ans = 0;
  for (int i = 0; i < cnt; ++i)
    if (!(x % p[i])) ans |= 1LL << i;
  return ans;
}
void down(int r, int L, int mid, int R) {
  int ls = r << 1;
  int rs = r << 1 | 1;
  (mul[ls] *= pow_mod(flag1[r], mid - L + 1)) %= mod;
  (flag1[ls] *= flag1[r]) %= mod;
  mask[ls] |= flag2[r];
  flag2[ls] |= flag2[r];
  (mul[rs] *= pow_mod(flag1[r], R - mid)) %= mod;
  (flag1[rs] *= flag1[r]) %= mod;
  mask[rs] |= flag2[r];
  flag2[rs] |= flag2[r];
  flag1[r] = 1;
  flag2[r] = 0;
}
pair<long long, long long> qry(int r, int L, int R, int x, int y) {
  if (L == x && R == y) return make_pair(mul[r], mask[r]);
  int mid = L + R >> 1;
  if (flag1[r] != 1 || flag2[r]) down(r, L, mid, R);
  if (y <= mid)
    return qry(r << 1, L, mid, x, y);
  else if (x > mid)
    return qry(r << 1 | 1, mid + 1, R, x, y);
  else {
    pair<long long, long long> ans1 = qry(r << 1, L, mid, x, mid);
    pair<long long, long long> ans2 = qry(r << 1 | 1, mid + 1, R, mid + 1, y);
    return make_pair(ans1.first * ans2.first % mod, ans1.second | ans2.second);
  }
}
void update(int r, int L, int R, int x, int y, int val, long long M) {
  if (L == x && R == y) {
    mul[r] *= pow_mod(val, R - L + 1);
    mul[r] %= mod;
    mask[r] |= M;
    flag1[r] *= val;
    flag1[r] %= mod;
    flag2[r] |= M;
    return;
  }
  int mid = L + R >> 1;
  if (flag1[r] != 1 || flag2[r]) down(r, L, mid, R);
  if (y <= mid)
    update(r << 1, L, mid, x, y, val, M);
  else if (x > mid)
    update(r << 1 | 1, mid + 1, R, x, y, val, M);
  else {
    update(r << 1, L, mid, x, mid, val, M);
    update(r << 1 | 1, mid + 1, R, mid + 1, y, val, M);
  }
  mul[r] = mul[r << 1] * mul[r << 1 | 1] % mod;
  mask[r] = mask[r << 1] | mask[r << 1 | 1];
}
int main() {
  for (int i = 2; i <= 300; ++i)
    if (prime(i)) {
      p[cnt] = i;
      inv[cnt++] = pow_mod(i, mod - 2);
    }
  scanf("%d%d", &n, &q);
  init(1, 1, n);
  while (q--) {
    scanf(" %s%d%d", cmd, &x, &y);
    if (cmd[0] == 'T') {
      pair<long long, long long> ans = qry(1, 1, n, x, y);
      for (int i = 0; i < cnt; ++i)
        if ((ans.second >> i) & 1) {
          ans.first *= inv[i];
          ans.first %= mod;
          ans.first *= p[i] - 1;
          ans.first %= mod;
        }
      printf("%I64d\n", ans.first);
    } else {
      scanf("%d", &z);
      update(1, 1, n, x, y, z, getmask(z));
    }
  }
  return 0;
}

### Prompt

Your task is to create 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 long long mod = 1000000007LL;
char cmd[100];
int x, y, z;
const int N = 400005;
bool prime(int x) {
  for (int i = 2; i * i <= x; ++i)
    if (!(x % i)) return 0;
  return 1;
}
long long pow_mod(long long a, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) (ans *= a) %= mod;
    (a *= a) %= mod;
    n >>= 1;
  }
  return ans;
}
int n, q, p[66], cnt = 0;
long long inv[66], mul[N << 2], mask[N << 2], flag1[N << 2], flag2[N << 2];
void init(int r, int L, int R) {
  flag1[r] = 1;
  if (L == R) {
    scanf("%I64d", mul + r);
    for (int i = 0; i < cnt; ++i)
      if (!(mul[r] % p[i])) mask[r] |= (1LL << i);
    return;
  }
  int mid = L + R >> 1;
  init(r << 1, L, mid);
  init(r << 1 | 1, mid + 1, R);
  mul[r] = mul[r << 1] * mul[r << 1 | 1] % mod;
  mask[r] = mask[r << 1] | mask[r << 1 | 1];
}
long long getmask(int x) {
  long long ans = 0;
  for (int i = 0; i < cnt; ++i)
    if (!(x % p[i])) ans |= 1LL << i;
  return ans;
}
void down(int r, int L, int mid, int R) {
  int ls = r << 1;
  int rs = r << 1 | 1;
  (mul[ls] *= pow_mod(flag1[r], mid - L + 1)) %= mod;
  (flag1[ls] *= flag1[r]) %= mod;
  mask[ls] |= flag2[r];
  flag2[ls] |= flag2[r];
  (mul[rs] *= pow_mod(flag1[r], R - mid)) %= mod;
  (flag1[rs] *= flag1[r]) %= mod;
  mask[rs] |= flag2[r];
  flag2[rs] |= flag2[r];
  flag1[r] = 1;
  flag2[r] = 0;
}
pair<long long, long long> qry(int r, int L, int R, int x, int y) {
  if (L == x && R == y) return make_pair(mul[r], mask[r]);
  int mid = L + R >> 1;
  if (flag1[r] != 1 || flag2[r]) down(r, L, mid, R);
  if (y <= mid)
    return qry(r << 1, L, mid, x, y);
  else if (x > mid)
    return qry(r << 1 | 1, mid + 1, R, x, y);
  else {
    pair<long long, long long> ans1 = qry(r << 1, L, mid, x, mid);
    pair<long long, long long> ans2 = qry(r << 1 | 1, mid + 1, R, mid + 1, y);
    return make_pair(ans1.first * ans2.first % mod, ans1.second | ans2.second);
  }
}
void update(int r, int L, int R, int x, int y, int val, long long M) {
  if (L == x && R == y) {
    mul[r] *= pow_mod(val, R - L + 1);
    mul[r] %= mod;
    mask[r] |= M;
    flag1[r] *= val;
    flag1[r] %= mod;
    flag2[r] |= M;
    return;
  }
  int mid = L + R >> 1;
  if (flag1[r] != 1 || flag2[r]) down(r, L, mid, R);
  if (y <= mid)
    update(r << 1, L, mid, x, y, val, M);
  else if (x > mid)
    update(r << 1 | 1, mid + 1, R, x, y, val, M);
  else {
    update(r << 1, L, mid, x, mid, val, M);
    update(r << 1 | 1, mid + 1, R, mid + 1, y, val, M);
  }
  mul[r] = mul[r << 1] * mul[r << 1 | 1] % mod;
  mask[r] = mask[r << 1] | mask[r << 1 | 1];
}
int main() {
  for (int i = 2; i <= 300; ++i)
    if (prime(i)) {
      p[cnt] = i;
      inv[cnt++] = pow_mod(i, mod - 2);
    }
  scanf("%d%d", &n, &q);
  init(1, 1, n);
  while (q--) {
    scanf(" %s%d%d", cmd, &x, &y);
    if (cmd[0] == 'T') {
      pair<long long, long long> ans = qry(1, 1, n, x, y);
      for (int i = 0; i < cnt; ++i)
        if ((ans.second >> i) & 1) {
          ans.first *= inv[i];
          ans.first %= mod;
          ans.first *= p[i] - 1;
          ans.first %= mod;
        }
      printf("%I64d\n", ans.first);
    } else {
      scanf("%d", &z);
      update(1, 1, n, x, y, z, getmask(z));
    }
  }
  return 0;
}

```