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;
char buf[1 << 15], *p1 = buf, *p2 = buf;
inline long long read() {
  char ch;
  bool flag = 0;
  long long res;
  while (!isdigit(
      ch = (p1 == p2 &&
                    (p2 = (p1 = buf) + fread(buf, 1, 1 << 15, stdin), p1 == p2)
                ? EOF
                : *p1++)))
    (ch == '-') && (flag = true);
  for (res = ch - '0'; isdigit(
           ch = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 15, stdin),
                             p1 == p2)
                     ? EOF
                     : *p1++));
       res = res * 10ll + ch - '0')
    ;
  (flag) && (res = -res);
  return res;
}
inline void write(long long x) {
  if (x < 0) x = ~x + 1ll, putchar('-');
  if (x > 9) write(x / 10ll);
  putchar(x % 10ll + '0');
}
long long prime[65];
long long inv[65];
int cnt = 0;
struct node {
  long long mul, tag, sta, sta_tag;
  node() {
    tag = 1;
    mul = 1;
    sta = 0;
    sta_tag = 0;
  }
};
node tree[3][401000 * 4];
int n, q;
const long long mod = 1e9 + 7;
long long fpow(long long x, long long v) {
  long long ans = 1;
  while (v) {
    if (v & 1) ans = ans * x % mod;
    x = x * x % mod;
    v >>= 1;
  }
  return ans % mod;
}
void init() {
  for (register int i = (2); i <= (300); i++) {
    bool flag = true;
    for (register int j = (2); j <= (i - 1); j++) {
      if (i % j == 0) {
        flag = false;
        break;
      }
    }
    if (flag) prime[++cnt] = i, inv[cnt] = fpow(i, mod - 2);
  }
}
char s[20];
void pushup(int c, int x) {
  tree[c][x].sta = tree[c][(x << 1)].sta | tree[c][((x << 1) | 1)].sta;
  tree[c][x].mul =
      tree[c][(x << 1)].mul % mod * tree[c][((x << 1) | 1)].mul % mod;
}
void pushdown(int c, int x, int l, int r) {
  if (tree[c][x].tag == 1) return;
  tree[c][(x << 1)].tag *= tree[c][x].tag % mod;
  tree[c][((x << 1) | 1)].tag *= tree[c][x].tag % mod;
  tree[c][(x << 1)].mul *= fpow(tree[c][x].tag, (((l + r) >> 1) - l + 1));
  tree[c][((x << 1) | 1)].mul *= fpow(tree[c][x].tag, (r - ((l + r) >> 1)));
  tree[c][(x << 1)].tag %= mod;
  tree[c][((x << 1) | 1)].tag %= mod;
  tree[c][(x << 1)].mul %= mod;
  tree[c][((x << 1) | 1)].mul %= mod;
  tree[c][(x << 1)].sta |= tree[c][x].sta_tag;
  tree[c][((x << 1) | 1)].sta |= tree[c][x].sta_tag;
  tree[c][(x << 1)].sta_tag |= tree[c][x].sta_tag;
  tree[c][((x << 1) | 1)].sta_tag |= tree[c][x].sta_tag;
  tree[c][x].sta_tag = 0;
  tree[c][x].tag = 1;
}
void build(int c, int x, int l, int r) {
  if (l == r) {
    cin >> tree[c][x].mul;
    for (long long i = 1; i <= cnt && prime[i] <= tree[c][x].mul; i++) {
      if (tree[c][x].mul % prime[i] == 0) {
        tree[c][x].sta |= (1ll << (i - 1ll));
      }
    }
    return;
  }
  build(c, (x << 1), l, ((l + r) >> 1));
  build(c, ((x << 1) | 1), ((l + r) >> 1) + 1, r);
  pushup(c, x);
}
void mul(int c, int x, int l, int r, int L, int R, long long v, long long sta) {
  if (L > r || R < l) return;
  pushdown(c, x, l, r);
  if (L <= l && r <= R) {
    tree[c][x].tag *= v;
    tree[c][x].mul *= fpow(v, (r - l + 1));
    tree[c][x].sta |= sta;
    tree[c][x].sta_tag |= sta;
    tree[c][x].tag %= mod;
    tree[c][x].mul %= mod;
    return;
  }
  mul(c, (x << 1), l, ((l + r) >> 1), L, R, v, sta);
  mul(c, ((x << 1) | 1), ((l + r) >> 1) + 1, r, L, R, v, sta);
  pushup(c, x);
}
pair<long long, long long> ask(int c, int x, int l, int r, int L, int R) {
  if (L > r || R < l) return make_pair(1, 0);
  pushdown(c, x, l, r);
  if (L <= l && r <= R) return make_pair(tree[c][x].mul, tree[c][x].sta);
  pair<long long, long long> tmp1 = ask(c, (x << 1), l, ((l + r) >> 1), L, R),
                             tmp2 = ask(c, ((x << 1) | 1), ((l + r) >> 1) + 1,
                                        r, L, R);
  return make_pair(tmp1.first % mod * tmp2.first % mod,
                   tmp1.second | tmp2.second);
}
void updata(long long x, int l, int r) {
  long long sta = 0;
  for (long long i = 1; i <= cnt && prime[i] <= x; i++) {
    if (x % prime[i] == 0) {
      sta |= (1ll << (i - 1ll));
    }
  }
  mul(1, 1, 1, n, l, r, x, sta);
}
long long query(int l, int r) {
  pair<long long, long long> res = ask(1, 1, 1, n, l, r);
  long long ans = res.first % mod;
  for (register int i = (1); i <= (cnt); i++) {
    if (res.second & (1ll << ((long long)i - 1ll)))
      ans = ans * inv[i] % mod * (prime[i] - 1ll) % mod;
  }
  return ans;
}
void solve() {
  cin >> n >> q;
  build(1, 1, 1, n);
  for (register int i = (1); i <= (q); i++) {
    cin >> s + 1;
    if (s[1] == 'M') {
      int l, r, x;
      cin >> l >> r >> x;
      updata(x, l, r);
    } else {
      int l, r;
      cin >> l >> r;
      long long tmp = query(l, r);
      cout << tmp % mod << endl;
    }
  }
}
int main() {
  init();
  solve();
}
