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;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') (c == '-') && (f = -1), c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
const long long mod = 1e9 + 7;
int vis[310], cnt;
long long a[400010], p[300], inv[300];
int n = read(), m = read();
struct tree {
  int l, r;
  long long mul, tag, bit, tbit;
  tree() { mul = 1, tag = 1, bit = 0, tbit = 0; }
} t[400010 << 2];
void pushup(int rt) {
  t[rt].mul = t[(rt << 1)].mul * t[(rt << 1 | 1)].mul % mod;
  t[rt].bit = t[(rt << 1)].bit | t[(rt << 1 | 1)].bit;
}
void build(int l, int r, int rt) {
  t[rt].l = l;
  t[rt].r = r;
  t[rt].tag = 1;
  if (l == r) {
    t[rt].mul = a[l] % mod;
    long long qwq = a[l];
    for (long long i = 0; qwq != 1 && i < cnt; ++i)
      if (qwq % p[i] == 0) {
        t[rt].bit |= (1ll << i);
        while (qwq % p[i] == 0) qwq /= p[i];
      }
    return;
  }
  build(l, ((l + r) >> 1), (rt << 1));
  build(((l + r) >> 1) + 1, r, (rt << 1 | 1));
  pushup(rt);
}
long long power(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
void pushdown(int ln, int rn, int rt) {
  if (t[rt].tag != 1 && t[rt].tbit != 0) {
    long long x = t[rt].tag;
    t[rt].tag = 1;
    t[(rt << 1)].tag *= x;
    t[(rt << 1 | 1)].tag *= x;
    t[(rt << 1)].tag %= mod;
    t[(rt << 1 | 1)].tag %= mod;
    t[(rt << 1)].mul = t[(rt << 1)].mul * power(x, ln) % mod;
    t[(rt << 1 | 1)].mul = t[(rt << 1 | 1)].mul * power(x, rn) % mod;
    t[(rt << 1)].tbit |= t[rt].tbit, t[(rt << 1 | 1)].tbit |= t[rt].tbit;
    t[(rt << 1)].bit |= t[rt].tbit;
    t[(rt << 1 | 1)].bit |= t[rt].tbit;
    t[rt].tbit = 0;
  }
}
void upd(int L, int R, long long c, int rt) {
  if (L <= (t[rt].l) && (t[rt].r) <= R) {
    t[rt].mul = t[rt].mul * power(c, (t[rt].r) - (t[rt].l) + 1) % mod;
    t[rt].tag = t[rt].tag * c % mod;
    for (long long i = 0; i < cnt && c != 1; ++i)
      if (c % p[i] == 0) {
        t[rt].bit |= (1ll << i);
        t[rt].tbit |= (1ll << i);
        while (c % p[i] == 0) c /= p[i];
      }
    return;
  }
  pushdown((((t[rt].l) + (t[rt].r)) >> 1) - (t[rt].l) + 1,
           (t[rt].r) - (((t[rt].l) + (t[rt].r)) >> 1), rt);
  if (L <= (((t[rt].l) + (t[rt].r)) >> 1)) upd(L, R, c, (rt << 1));
  if (R > (((t[rt].l) + (t[rt].r)) >> 1)) upd(L, R, c, (rt << 1 | 1));
  pushup(rt);
}
long long query(int L, int R, int rt) {
  long long ans = 1;
  if (L <= (t[rt].l) && (t[rt].r) <= R) return t[rt].mul % mod;
  pushdown((((t[rt].l) + (t[rt].r)) >> 1) - (t[rt].l) + 1,
           (t[rt].r) - (((t[rt].l) + (t[rt].r)) >> 1), rt);
  if (L <= (((t[rt].l) + (t[rt].r)) >> 1))
    ans = ans * query(L, R, (rt << 1)) % mod;
  if (R > (((t[rt].l) + (t[rt].r)) >> 1))
    ans = ans * query(L, R, (rt << 1 | 1)) % mod;
  return ans % mod;
}
long long querybit(int L, int R, int rt) {
  long long ans = 0;
  if (L <= (t[rt].l) && (t[rt].r) <= R) return t[rt].bit;
  pushdown((((t[rt].l) + (t[rt].r)) >> 1) - (t[rt].l) + 1,
           (t[rt].r) - (((t[rt].l) + (t[rt].r)) >> 1), rt);
  if (L <= (((t[rt].l) + (t[rt].r)) >> 1)) ans |= querybit(L, R, (rt << 1));
  if (R > (((t[rt].l) + (t[rt].r)) >> 1)) ans |= querybit(L, R, (rt << 1 | 1));
  return ans;
}
void init(int n) {
  for (int i = 2; i <= n; ++i) {
    if (!vis[i]) p[cnt] = i, inv[cnt] = power(p[cnt], mod - 2), ++cnt;
    for (int j = 0; j < cnt && i * p[j] <= n; ++j) {
      vis[i * p[j]] = 1;
      if (i % p[j] == 0) break;
    }
  }
}
int main() {
  init(300);
  for (int i = 1; i <= n; ++i) (a[i] = read());
  build(1, n, 1);
  while (m--) {
    char c[10];
    scanf("%s", c);
    int l = read(), r = read();
    if (c[0] == 'M') {
      long long x = read();
      upd(l, r, x, 1);
    } else {
      long long ans = query(l, r, 1), f = querybit(l, r, 1);
      for (long long i = 0; i < 63; ++i)
        if (f & (1ll << i))
          ans = (long long)ans * (p[i] - 1) % mod * inv[i] % mod;
      printf("%lld\n", ans % mod);
    }
  }
}
