#include <bits/stdc++.h>
using namespace std;
const int N = 400500, M = 305, B = 62, mod = (int)1e9 + 7;
long long INF = (long long)1e18 + 50;
int n, q;
long long mask[M];
long long invp[B];
vector<int> pms;
long long num[N];
long long fp(long long x, long long k) {
  if (k == 0) return 1;
  long long hf = fp(x, k / 2);
  return k % 2 ? hf * hf % mod * x % mod : hf * hf % mod;
}
long long inv(long long x) { return fp(x, mod - 2); }
bool is_prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
struct node {
  long long dat, add, prod, bas;
  void merge(node &l, node &r) {
    prod = l.prod * r.prod % mod;
    dat = l.dat | r.dat;
  }
};
struct Tree {
  node nds[4 * N];
  void push_down(int x, int l, int r) {
    node &cur = nds[x];
    if (cur.add != 0) {
      if (l < r) {
        int mid = (l + r) / 2;
        node &lson = nds[x * 2 + 1], &rson = nds[x * 2 + 2];
        lson.dat |= cur.add;
        lson.add |= cur.add;
        rson.dat |= cur.add;
        rson.add |= cur.add;
        lson.prod *= fp(cur.bas, mid - l + 1);
        lson.prod %= mod;
        lson.bas *= cur.bas;
        lson.bas %= mod;
        rson.prod *= fp(cur.bas, r - mid);
        rson.prod %= mod;
        rson.bas *= cur.bas;
        rson.bas %= mod;
      }
      cur.add = 0;
      cur.bas = 1;
    }
  }
  void init(int x = 0, int l = 0, int r = n - 1) {
    nds[x].add = 0;
    nds[x].bas = 1;
    if (l == r) {
      nds[x].dat = mask[num[l]];
      nds[x].prod = num[l];
      return;
    }
    int mid = (l + r) / 2;
    init(x * 2 + 1, l, mid);
    init(x * 2 + 2, mid + 1, r);
    nds[x].merge(nds[x * 2 + 1], nds[x * 2 + 2]);
  }
  node query(int a, int b, int x = 0, int l = 0, int r = n - 1) {
    int mid = (l + r) / 2;
    if (r < a || l > b) return {0, 0, 1, 0};
    push_down(x, l, r);
    if (l >= a && r <= b) return nds[x];
    node LHS = query(a, b, x * 2 + 1, l, mid);
    node RHS = query(a, b, x * 2 + 2, mid + 1, r);
    node res;
    res.merge(LHS, RHS);
    return res;
  }
  void update(int a, int b, int x, int l, int r, int val) {
    int mid = (l + r) / 2;
    if (r < a || l > b) return;
    if (l < r) push_down(x, l, r);
    if (l >= a && r <= b) {
      nds[x].dat |= mask[val];
      nds[x].add |= mask[val];
      nds[x].bas *= val;
      nds[x].bas %= mod;
      nds[x].prod *= fp(val, r - l + 1);
      nds[x].prod %= mod;
      return;
    }
    update(a, b, x * 2 + 1, l, mid, val);
    update(a, b, x * 2 + 2, mid + 1, r, val);
    nds[x].merge(nds[x * 2 + 1], nds[x * 2 + 2]);
  }
  void update(int a, int b, int val) { update(a, b, 0, 0, n - 1, val); }
} tree;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 2; i <= 300; i++)
    if (is_prime(i)) pms.push_back(i);
  assert(pms.size() == B);
  for (int i = 0; i <= 300; i++) {
    for (int j = 0; j < B; j++)
      if (i % pms[j] == 0) mask[i] |= (1LL << j);
  }
  for (int i = 0; i < B; i++) invp[i] = inv(pms[i]);
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> num[i];
  tree.init(0, 0, n - 1);
  while (q--) {
    string s;
    int l, r;
    cin >> s >> l >> r;
    l--, r--;
    if (s[0] == 'T') {
      node nd = tree.query(l, r);
      long long res = nd.prod;
      for (int j = 0; j < B; j++) {
        if (nd.dat & (1LL << j)) {
          res *= (pms[j] - 1) * invp[j] % mod;
          res %= mod;
        }
      }
      cout << res << "\n";
    } else {
      int val;
      cin >> val;
      tree.update(l, r, val);
    }
  }
}

### Prompt

Generate 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 N = 400500, M = 305, B = 62, mod = (int)1e9 + 7;
long long INF = (long long)1e18 + 50;
int n, q;
long long mask[M];
long long invp[B];
vector<int> pms;
long long num[N];
long long fp(long long x, long long k) {
  if (k == 0) return 1;
  long long hf = fp(x, k / 2);
  return k % 2 ? hf * hf % mod * x % mod : hf * hf % mod;
}
long long inv(long long x) { return fp(x, mod - 2); }
bool is_prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
struct node {
  long long dat, add, prod, bas;
  void merge(node &l, node &r) {
    prod = l.prod * r.prod % mod;
    dat = l.dat | r.dat;
  }
};
struct Tree {
  node nds[4 * N];
  void push_down(int x, int l, int r) {
    node &cur = nds[x];
    if (cur.add != 0) {
      if (l < r) {
        int mid = (l + r) / 2;
        node &lson = nds[x * 2 + 1], &rson = nds[x * 2 + 2];
        lson.dat |= cur.add;
        lson.add |= cur.add;
        rson.dat |= cur.add;
        rson.add |= cur.add;
        lson.prod *= fp(cur.bas, mid - l + 1);
        lson.prod %= mod;
        lson.bas *= cur.bas;
        lson.bas %= mod;
        rson.prod *= fp(cur.bas, r - mid);
        rson.prod %= mod;
        rson.bas *= cur.bas;
        rson.bas %= mod;
      }
      cur.add = 0;
      cur.bas = 1;
    }
  }
  void init(int x = 0, int l = 0, int r = n - 1) {
    nds[x].add = 0;
    nds[x].bas = 1;
    if (l == r) {
      nds[x].dat = mask[num[l]];
      nds[x].prod = num[l];
      return;
    }
    int mid = (l + r) / 2;
    init(x * 2 + 1, l, mid);
    init(x * 2 + 2, mid + 1, r);
    nds[x].merge(nds[x * 2 + 1], nds[x * 2 + 2]);
  }
  node query(int a, int b, int x = 0, int l = 0, int r = n - 1) {
    int mid = (l + r) / 2;
    if (r < a || l > b) return {0, 0, 1, 0};
    push_down(x, l, r);
    if (l >= a && r <= b) return nds[x];
    node LHS = query(a, b, x * 2 + 1, l, mid);
    node RHS = query(a, b, x * 2 + 2, mid + 1, r);
    node res;
    res.merge(LHS, RHS);
    return res;
  }
  void update(int a, int b, int x, int l, int r, int val) {
    int mid = (l + r) / 2;
    if (r < a || l > b) return;
    if (l < r) push_down(x, l, r);
    if (l >= a && r <= b) {
      nds[x].dat |= mask[val];
      nds[x].add |= mask[val];
      nds[x].bas *= val;
      nds[x].bas %= mod;
      nds[x].prod *= fp(val, r - l + 1);
      nds[x].prod %= mod;
      return;
    }
    update(a, b, x * 2 + 1, l, mid, val);
    update(a, b, x * 2 + 2, mid + 1, r, val);
    nds[x].merge(nds[x * 2 + 1], nds[x * 2 + 2]);
  }
  void update(int a, int b, int val) { update(a, b, 0, 0, n - 1, val); }
} tree;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 2; i <= 300; i++)
    if (is_prime(i)) pms.push_back(i);
  assert(pms.size() == B);
  for (int i = 0; i <= 300; i++) {
    for (int j = 0; j < B; j++)
      if (i % pms[j] == 0) mask[i] |= (1LL << j);
  }
  for (int i = 0; i < B; i++) invp[i] = inv(pms[i]);
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> num[i];
  tree.init(0, 0, n - 1);
  while (q--) {
    string s;
    int l, r;
    cin >> s >> l >> r;
    l--, r--;
    if (s[0] == 'T') {
      node nd = tree.query(l, r);
      long long res = nd.prod;
      for (int j = 0; j < B; j++) {
        if (nd.dat & (1LL << j)) {
          res *= (pms[j] - 1) * invp[j] % mod;
          res %= mod;
        }
      }
      cout << res << "\n";
    } else {
      int val;
      cin >> val;
      tree.update(l, r, val);
    }
  }
}

```