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>
#pragma warning(disable : 4996);
const double eps = 1e-8;
const int MAXN = 4e5 + 5;
const int MAXM = 2e6 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
using namespace std;
const int M = 300;
int p[64], pNum;
bool f[M] = {1, 1};
void Prime() {
  int i, j;
  for (i = 2; i < M; i++) {
    if (!f[i]) {
      p[pNum++] = i;
    }
    for (j = 0; j < pNum && p[j] * i < M; j++) {
      f[p[j] * i] = 1;
      if (!(i % p[j])) break;
    }
  }
}
long long a[MAXN], sum[MAXN << 2], mul[MAXN << 2];
long long quickmod(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      ans = ans * a % MOD;
    }
    b >>= 1;
    a = a * a % MOD;
  }
  return ans;
}
void pushup(int rt) { sum[rt] = sum[rt << 1] * sum[rt << 1 | 1] % MOD; }
void build(int l, int r, int rt) {
  mul[rt] = 1, sum[rt] = 1;
  if (l == r) {
    sum[rt] = a[l];
    return;
  }
  build(l, ((l + r) >> 1), rt << 1), build(((l + r) >> 1) + 1, r, rt << 1 | 1);
  pushup(rt);
}
void pushdown(int m, int rt) {
  if (mul[rt] != 1) {
    mul[rt << 1] = mul[rt << 1] * mul[rt] % MOD;
    mul[rt << 1 | 1] = mul[rt << 1 | 1] * mul[rt] % MOD;
    sum[rt << 1] = sum[rt << 1] * quickmod(mul[rt], (m - (m >> 1))) % MOD;
    sum[rt << 1 | 1] = sum[rt << 1 | 1] * quickmod(mul[rt], m >> 1) % MOD;
    mul[rt] = 1;
  }
}
long long query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return sum[rt];
  }
  pushdown(r - l + 1, rt);
  long long ret = 1;
  int mid = (l + r) / 2;
  if (L <= mid) ret = ret * query(L, R, l, ((l + r) >> 1), rt << 1) % MOD;
  if (R > mid)
    ret = ret * query(L, R, ((l + r) >> 1) + 1, r, rt << 1 | 1) % MOD;
  return ret;
}
void update(int L, int R, long long c, int l, int r, int rt) {
  if (L <= l && r <= R) {
    sum[rt] = sum[rt] * quickmod(c, r - l + 1) % MOD;
    mul[rt] = mul[rt] * c % MOD;
    return;
  }
  pushdown(r - l + 1, rt);
  int mid = (l + r) / 2;
  if (L <= mid) update(L, R, c, l, ((l + r) >> 1), rt << 1);
  if (R > mid) update(L, R, c, ((l + r) >> 1) + 1, r, rt << 1 | 1);
  pushup(rt);
}
long long a2[MAXN], val[MAXN << 2], lazy[MAXN << 2];
void orpushup(int rt) { val[rt] |= val[rt << 1] | val[rt << 1 | 1]; }
void orbuild(int l, int r, int rt) {
  lazy[rt] = 0, val[rt] = 0;
  if (l == r) {
    val[rt] = a2[l];
    return;
  }
  orbuild(l, ((l + r) >> 1), rt << 1),
      orbuild(((l + r) >> 1) + 1, r, rt << 1 | 1);
  orpushup(rt);
}
void orpushdown(int rt) {
  if (lazy[rt]) {
    lazy[rt << 1] |= lazy[rt];
    lazy[rt << 1 | 1] |= lazy[rt];
    val[rt << 1] |= lazy[rt];
    val[rt << 1 | 1] |= lazy[rt];
    lazy[rt] = 0;
  }
}
long long orquery(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return val[rt];
  }
  orpushdown(rt);
  int mid = (l + r) / 2;
  long long ret = 0;
  if (L <= mid) ret |= orquery(L, R, l, ((l + r) >> 1), rt << 1);
  if (R > mid) ret |= orquery(L, R, ((l + r) >> 1) + 1, r, rt << 1 | 1);
  return ret;
}
void orupdate(int L, int R, long long c, int l, int r, int rt) {
  if (L <= l && r <= R) {
    lazy[rt] |= c;
    val[rt] |= c;
    return;
  }
  orpushdown(rt);
  int mid = (l + r) / 2;
  if (L <= mid) orupdate(L, R, c, l, ((l + r) >> 1), rt << 1);
  if (R > mid) orupdate(L, R, c, ((l + r) >> 1) + 1, r, rt << 1 | 1);
  orpushup(rt);
}
vector<pair<long long, long long> > factor;
void init(long long n) {
  factor.clear();
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      factor.emplace_back(i, 0);
      for (; n % i == 0; n /= i) factor.back().second++;
    }
  }
  if (n > 1) factor.emplace_back(n, 1);
}
int id[M];
long long pcp_1[M];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  Prime();
  for (int i = 0; i < 62; i++) id[p[i]] = i;
  for (int i = 0; i < 62; i++)
    pcp_1[i] = 1ll * (p[i] - 1) * quickmod(p[i], MOD - 2) % MOD;
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  build(1, n, 1);
  for (int i = 1; i <= n; i++) {
    init(a[i]);
    a2[i] = 0;
    for (auto it : factor) a2[i] |= (1ll << id[it.first]);
  }
  orbuild(1, n, 1);
  while (q--) {
    char op[20];
    int l, r, c;
    cin >> op >> l >> r;
    if (op[0] == 'T') {
      long long B = orquery(l, r, 1, n, 1);
      long long ans = 1;
      for (int i = 0; i < 62; i++) {
        if (B & (1ll << i)) {
          ans = ans * pcp_1[i] % MOD;
        }
      }
      cout << ans * query(l, r, 1, n, 1) % MOD << endl;
    } else {
      cin >> c;
      init(c);
      long long B = 0;
      for (auto it : factor) B |= (1ll << id[it.first]);
      update(l, r, c, 1, n, 1);
      orupdate(l, r, B, 1, n, 1);
    }
  }
}
