#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int num;
bool vis[310];
long long pri[65];
long long factor[310];
long long inv[65];
long long ans1, ans2;
struct Node {
  int left, right;
  long long val;
  long long in;
  long long f, inf;
} node[400010 << 2];
long long PowerMod(long long a, long long b, long long c) {
  long long ans = 1;
  long long k;
  k = a;
  k = k % c;
  while (b > 0) {
    if (b & 1) ans = (ans * k) % c;
    b >>= 1;
    k = (k * k) % c;
  }
  return ans;
}
void init() {
  for (long long i = 2; i <= 300; i++) {
    if (vis[i] == false) pri[num++] = i;
    for (long long j = 0; j < num && i * pri[j] <= 300; j++) {
      vis[i * pri[j]] = true;
      if (i % pri[j] == 0) break;
    }
  }
  for (int i = 0; i < num; i++) inv[i] = PowerMod(pri[i], MOD - 2, MOD);
  for (int i = 2; i <= 300; i++) {
    long long temp = i;
    for (int j = 0; j < num && pri[j] <= temp; j++) {
      if (temp % pri[j] == 0) {
        factor[i] |= 1ll << j;
        while (temp % pri[j] == 0) temp /= pri[j];
      }
    }
  }
}
void build(int l, int r, int id) {
  node[id].left = l;
  node[id].right = r;
  node[id].in = 0;
  node[id].f = 1;
  node[id].inf = 0;
  if (l == r) {
    scanf("%lld", &node[id].val);
    node[id].in |= factor[node[id].val];
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, id << 1);
  build(m + 1, r, id << 1 | 1);
  node[id].val = node[id << 1].val * node[id << 1 | 1].val % MOD;
  node[id].in = node[id << 1].in | node[id << 1 | 1].in;
}
void down(int id) {
  int l1 = node[id << 1].left, r1 = node[id << 1].right;
  int l2 = node[id << 1 | 1].left, r2 = node[id << 1 | 1].right;
  node[id << 1].f = node[id << 1].f * node[id].f % MOD;
  node[id << 1 | 1].f = node[id << 1 | 1].f * node[id].f % MOD;
  node[id << 1].val =
      node[id << 1].val * PowerMod(node[id].f, r1 - l1 + 1, MOD) % MOD;
  node[id << 1 | 1].val =
      node[id << 1 | 1].val * PowerMod(node[id].f, r2 - l2 + 1, MOD) % MOD;
  node[id << 1].inf |= node[id].inf;
  node[id << 1 | 1].inf |= node[id].inf;
  node[id << 1].in |= node[id].inf;
  node[id << 1 | 1].in |= node[id].inf;
  node[id].f = 1;
  node[id].inf = 0;
}
void query(int L, int R, int id) {
  int l = node[id].left, r = node[id].right;
  if (l >= L && r <= R) {
    ans1 = ans1 * node[id].val % MOD;
    ans2 |= node[id].in;
    return;
  }
  if (node[id].f != 1 || node[id].inf != 0) down(id);
  int m = (l + r) >> 1;
  if (L <= m) query(L, R, id << 1);
  if (R > m) query(L, R, id << 1 | 1);
}
void update(int L, int R, long long x, int id) {
  int l = node[id].left, r = node[id].right;
  if (l >= L && r <= R) {
    node[id].val = node[id].val * PowerMod(x, r - l + 1, MOD) % MOD;
    node[id].in |= factor[x];
    node[id].f = node[id].f * x % MOD;
    node[id].inf |= factor[x];
    return;
  }
  if (node[id].f != 1 || node[id].inf != 0) down(id);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, x, id << 1);
  if (R > m) update(L, R, x, id << 1 | 1);
  node[id].val = node[id << 1].val * node[id << 1 | 1].val % MOD;
  node[id].in = node[id << 1].in | node[id << 1 | 1].in;
}
int main() {
  init();
  int n, q, x, y;
  long long z;
  char s[10];
  scanf("%d%d", &n, &q);
  build(1, n, 1);
  scanf("%d", &q);
  while (q--) {
    scanf("%s", s);
    if (s[0] == 'M') {
      scanf("%d%d%lld", &x, &y, &z);
      update(x, y, z, 1);
    } else if (s[0] == 'T') {
      scanf("%d%d", &x, &y);
      ans1 = 1;
      ans2 = 0;
      query(x, y, 1);
      if (ans1 == 1 && ans2 == 0) {
        printf("1\n");
        continue;
      }
      long long ans = ans1;
      for (int i = 0; i < 62; i++) {
        if (ans2 >> i & 1) ans = ans * (pri[i] - 1) % MOD * inv[i] % MOD;
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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 = 1000000007;
int num;
bool vis[310];
long long pri[65];
long long factor[310];
long long inv[65];
long long ans1, ans2;
struct Node {
  int left, right;
  long long val;
  long long in;
  long long f, inf;
} node[400010 << 2];
long long PowerMod(long long a, long long b, long long c) {
  long long ans = 1;
  long long k;
  k = a;
  k = k % c;
  while (b > 0) {
    if (b & 1) ans = (ans * k) % c;
    b >>= 1;
    k = (k * k) % c;
  }
  return ans;
}
void init() {
  for (long long i = 2; i <= 300; i++) {
    if (vis[i] == false) pri[num++] = i;
    for (long long j = 0; j < num && i * pri[j] <= 300; j++) {
      vis[i * pri[j]] = true;
      if (i % pri[j] == 0) break;
    }
  }
  for (int i = 0; i < num; i++) inv[i] = PowerMod(pri[i], MOD - 2, MOD);
  for (int i = 2; i <= 300; i++) {
    long long temp = i;
    for (int j = 0; j < num && pri[j] <= temp; j++) {
      if (temp % pri[j] == 0) {
        factor[i] |= 1ll << j;
        while (temp % pri[j] == 0) temp /= pri[j];
      }
    }
  }
}
void build(int l, int r, int id) {
  node[id].left = l;
  node[id].right = r;
  node[id].in = 0;
  node[id].f = 1;
  node[id].inf = 0;
  if (l == r) {
    scanf("%lld", &node[id].val);
    node[id].in |= factor[node[id].val];
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, id << 1);
  build(m + 1, r, id << 1 | 1);
  node[id].val = node[id << 1].val * node[id << 1 | 1].val % MOD;
  node[id].in = node[id << 1].in | node[id << 1 | 1].in;
}
void down(int id) {
  int l1 = node[id << 1].left, r1 = node[id << 1].right;
  int l2 = node[id << 1 | 1].left, r2 = node[id << 1 | 1].right;
  node[id << 1].f = node[id << 1].f * node[id].f % MOD;
  node[id << 1 | 1].f = node[id << 1 | 1].f * node[id].f % MOD;
  node[id << 1].val =
      node[id << 1].val * PowerMod(node[id].f, r1 - l1 + 1, MOD) % MOD;
  node[id << 1 | 1].val =
      node[id << 1 | 1].val * PowerMod(node[id].f, r2 - l2 + 1, MOD) % MOD;
  node[id << 1].inf |= node[id].inf;
  node[id << 1 | 1].inf |= node[id].inf;
  node[id << 1].in |= node[id].inf;
  node[id << 1 | 1].in |= node[id].inf;
  node[id].f = 1;
  node[id].inf = 0;
}
void query(int L, int R, int id) {
  int l = node[id].left, r = node[id].right;
  if (l >= L && r <= R) {
    ans1 = ans1 * node[id].val % MOD;
    ans2 |= node[id].in;
    return;
  }
  if (node[id].f != 1 || node[id].inf != 0) down(id);
  int m = (l + r) >> 1;
  if (L <= m) query(L, R, id << 1);
  if (R > m) query(L, R, id << 1 | 1);
}
void update(int L, int R, long long x, int id) {
  int l = node[id].left, r = node[id].right;
  if (l >= L && r <= R) {
    node[id].val = node[id].val * PowerMod(x, r - l + 1, MOD) % MOD;
    node[id].in |= factor[x];
    node[id].f = node[id].f * x % MOD;
    node[id].inf |= factor[x];
    return;
  }
  if (node[id].f != 1 || node[id].inf != 0) down(id);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, x, id << 1);
  if (R > m) update(L, R, x, id << 1 | 1);
  node[id].val = node[id << 1].val * node[id << 1 | 1].val % MOD;
  node[id].in = node[id << 1].in | node[id << 1 | 1].in;
}
int main() {
  init();
  int n, q, x, y;
  long long z;
  char s[10];
  scanf("%d%d", &n, &q);
  build(1, n, 1);
  scanf("%d", &q);
  while (q--) {
    scanf("%s", s);
    if (s[0] == 'M') {
      scanf("%d%d%lld", &x, &y, &z);
      update(x, y, z, 1);
    } else if (s[0] == 'T') {
      scanf("%d%d", &x, &y);
      ans1 = 1;
      ans2 = 0;
      query(x, y, 1);
      if (ans1 == 1 && ans2 == 0) {
        printf("1\n");
        continue;
      }
      long long ans = ans1;
      for (int i = 0; i < 62; i++) {
        if (ans2 >> i & 1) ans = ans * (pri[i] - 1) % MOD * inv[i] % MOD;
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}

```