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;
template <typename T>
void maxtt(T &t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T &t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "URDL";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
vector<int> ps;
long long fp[303], invp[66];
bool isp(int x) {
  for (int i = 2; i < x; i++)
    if (x % i == 0) return 0;
  return 1;
}
void init() {
  for (int i = 2; i < 300; i++)
    if (isp(i)) ps.push_back(i);
  for (int i = 2; i <= 300; i++) {
    for (int(j) = 0; (j) < (int)(62); (j)++)
      if (i % ps[j] == 0) fp[i] |= 1LL << j;
  }
  for (int(j) = 0; (j) < (int)(62); (j)++) {
    invp[j] =
        (long long)(ps[j] - 1) * fastPow(ps[j], 1000000007 - 2) % 1000000007;
  }
}
struct nd {
  int ss;
  long long bs;
  nd() {
    ss = 1;
    bs = 0;
  }
  friend nd operator+(const nd &x, const nd &y) {
    nd res = nd();
    res.ss = (long long)x.ss * y.ss % 1000000007;
    res.bs = x.bs | y.bs;
    return res;
  }
} T[400135 << 2];
int lz[400135 << 2];
long long lzb[400135 << 2];
int a[400135];
void Up(int rt, int l, int r) { T[rt] = T[(rt << 1)] + T[(rt << 1 | 1)]; }
void Down(int rt, int l, int r) {
  if (l + 1 == r) return;
  int mid = (l + r) / 2;
  if (lz[rt] != 1) {
    T[(rt << 1)].ss =
        (long long)T[(rt << 1)].ss * fastPow(lz[rt], mid - l) % 1000000007;
    lz[(rt << 1)] = (long long)lz[(rt << 1)] * lz[rt] % 1000000007;
    T[(rt << 1 | 1)].ss =
        (long long)T[(rt << 1 | 1)].ss * fastPow(lz[rt], r - mid) % 1000000007;
    lz[(rt << 1 | 1)] = (long long)lz[(rt << 1 | 1)] * lz[rt] % 1000000007;
    lz[rt] = 1;
  }
  if (lzb[rt] != 0) {
    T[(rt << 1)].bs |= lzb[rt];
    lzb[(rt << 1)] |= lzb[rt];
    T[(rt << 1 | 1)].bs |= lzb[rt];
    lzb[(rt << 1 | 1)] |= lzb[rt];
    lzb[rt] = 0;
  }
}
void upt(int rt, int l, int r, int L, int R, int val) {
  if (R <= l || r <= L) return;
  if (L <= l && r <= R) {
    T[rt].ss = (long long)T[rt].ss * fastPow(val, r - l) % 1000000007;
    lz[rt] = (long long)lz[rt] * val % 1000000007;
    T[rt].bs |= fp[val];
    lzb[rt] |= fp[val];
    return;
  }
  Down(rt, l, r);
  int mid = (l + r) / 2;
  upt((rt << 1), l, mid, L, R, val);
  upt((rt << 1 | 1), mid, r, L, R, val);
  Up(rt, l, r);
}
nd qy(int rt, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    return T[rt];
  }
  Down(rt, l, r);
  int mid = (l + r) / 2;
  if (R <= mid)
    return qy((rt << 1), l, mid, L, R);
  else if (L >= mid)
    return qy((rt << 1 | 1), mid, r, L, R);
  else
    return qy((rt << 1), l, mid, L, mid) + qy((rt << 1 | 1), mid, r, mid, R);
}
void build(int rt, int l, int r) {
  if (l + 1 == r) {
    T[rt].ss = a[r];
    T[rt].bs = fp[a[r]];
    return;
  }
  int mid = (l + r) / 2;
  build((rt << 1), l, mid);
  build((rt << 1 | 1), mid, r);
  Up(rt, l, r);
}
void fmain(int tid) {
  scanf("%d%d", &n, &m);
  init();
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d", a + i);
  for (int(i) = 0; (i) < (int)(400135 * 4); (i)++) lz[i] = 1;
  build(1, 0, n);
  char s[20];
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    int l, r, x;
    scanf("%s%d%d", s, &l, &r);
    if (s[0] == 'M') {
      scanf("%d", &x);
      upt(1, 0, n, l - 1, r, x);
    } else {
      nd z = qy(1, 0, n, l - 1, r);
      int ans = z.ss;
      for (int(j) = 0; (j) < (int)(62); (j)++)
        if (z.bs & (1LL << j)) {
          ans = (long long)ans * invp[j] % 1000000007;
        }
      printf("%d\n", ans);
    }
  }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
