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.
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, N = 4e5 + 2;
int n, q, arr[N];
long long mask[302], Coef[302];
long long andLazy[4 * N], mulLazy[4 * N], aintAnd[4 * N], aintMul[4 * N];
vector<int> primes;
void multo(long long &x, long long y) { x = x * y % MOD; }
long long lgput(long long x, long long y) {
  auto res = 1LL;
  for (; y; y /= 2) {
    if (y & 1) multo(res, x);
    multo(x, x);
  }
  return res;
}
void gen_primes() {
  vector<bool> ep(301, 1);
  for (int i = 2; i <= 300; ++i) {
    if (ep[i]) {
      primes.push_back(i);
      mask[i] |= 1LL << (primes.size() - 1);
      for (int j = i + i; j <= 300; j += i) {
        ep[j] = 0;
        mask[j] |= 1LL << (primes.size() - 1);
      }
    }
  }
}
void pass_mul(int st, int dr, int nod) {
  int mid = (st + dr) / 2;
  int l1 = mid - st + 1, l2 = dr - (mid + 1) + 1;
  multo(mulLazy[2 * nod], mulLazy[nod]);
  multo(mulLazy[2 * nod + 1], mulLazy[nod]);
  multo(aintMul[2 * nod], lgput(mulLazy[nod], l1));
  multo(aintMul[2 * nod + 1], lgput(mulLazy[nod], l2));
  mulLazy[nod] = 1;
}
void pass_and(int nod) {
  andLazy[2 * nod] |= andLazy[nod];
  andLazy[2 * nod + 1] |= andLazy[nod];
  aintAnd[2 * nod] |= andLazy[nod];
  aintAnd[2 * nod + 1] |= andLazy[nod];
  andLazy[nod] = 0;
}
void mul_range(int x, int y, long long with, int st, int dr, int nod) {
  if (x > dr || st > y) {
    return;
  }
  if (st >= x && dr <= y) {
    multo(mulLazy[nod], with);
    multo(aintMul[nod], lgput(with, dr - st + 1));
    return;
  }
  pass_mul(st, dr, nod);
  int mid = (st + dr) / 2;
  mul_range(x, y, with, st, mid, 2 * nod);
  mul_range(x, y, with, mid + 1, dr, nod * 2 + 1);
  aintMul[nod] = aintMul[2 * nod] * aintMul[2 * nod + 1] % MOD;
}
long long mul_query(int x, int y, int st, int dr, int nod) {
  if (x > dr || st > y) {
    return 1;
  }
  if (st >= x && dr <= y) {
    return aintMul[nod];
  }
  pass_mul(st, dr, nod);
  int mid = (st + dr) / 2;
  return mul_query(x, y, st, mid, 2 * nod) *
         mul_query(x, y, mid + 1, dr, 2 * nod + 1) % MOD;
}
void and_range(int x, int y, long long with, int st, int dr, int nod) {
  if (x > dr || st > y) {
    return;
  }
  if (st >= x && dr <= y) {
    andLazy[nod] |= with, aintAnd[nod] |= with;
    return;
  }
  pass_and(nod);
  int mid = (st + dr) / 2;
  and_range(x, y, with, st, mid, 2 * nod);
  and_range(x, y, with, mid + 1, dr, nod * 2 + 1);
  aintAnd[nod] = aintAnd[2 * nod] | aintAnd[2 * nod + 1];
}
long long and_query(int x, int y, int st, int dr, int nod) {
  if (x > dr || st > y) {
    return 0;
  }
  if (st >= x && dr <= y) {
    return aintAnd[nod];
  }
  pass_and(nod);
  int mid = (st + dr) / 2;
  return and_query(x, y, st, mid, 2 * nod) |
         and_query(x, y, mid + 1, dr, 2 * nod + 1);
}
int32_t main() {
  ios::sync_with_stdio(0);
  gen_primes();
  for (int i = 0; i < 62; ++i) {
    Coef[i] = primes[i] - 1;
    multo(Coef[i], lgput(primes[i], MOD - 2));
  }
  cin >> n >> q;
  for (int i = 1; i <= 4 * n; ++i) {
    aintMul[i] = 1;
    mulLazy[i] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    mul_range(i, i, arr[i], 1, n, 1);
    and_range(i, i, mask[arr[i]], 1, n, 1);
  }
  for (int i = 1; i <= q; ++i) {
    string op;
    int l, r;
    cin >> op >> l >> r;
    if (op[0] == 'T') {
      long long x = mul_query(l, r, 1, n, 1);
      long long primes_in = and_query(l, r, 1, n, 1);
      for (int j = 0; j < 62; ++j)
        if (primes_in & (1LL << j)) multo(x, Coef[j]);
      cout << x << '\n';
    } else {
      int x;
      cin >> x;
      mul_range(l, r, x, 1, n, 1);
      and_range(l, r, mask[x], 1, n, 1);
    }
  }
}
