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 inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-6;
const double pi = 3.14159265358979;
const int maxn = 4e5 + 5;
const int maxm = 2e5 + 5;
const long long mod = 1e9 + 7;
inline int read() {
  int ans = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) ans = (ans << 3) + (ans << 1) + (ch ^ 48), ch = getchar();
  return ans;
}
inline long long pow_(long long a, long long b, long long p) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return ret;
}
bool isprime[305];
int prime[70], tot = -1;
int inv_prime[70];
void init() {
  for (int i = 2; i <= 300; ++i) isprime[i] = false;
  for (int i = 2; i <= 300; ++i) {
    if (!isprime[i]) prime[++tot] = i, inv_prime[tot] = pow_(i, mod - 2, mod);
    for (int j = 0; j <= tot && i * prime[j] <= 300; ++j) {
      isprime[i * prime[j]] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
long long find_prime(long long x) {
  unsigned long long ret = 0;
  for (int i = 0; i <= tot; ++i)
    if (x == x / prime[i] * prime[i]) ret |= ((long long)1 << i);
  return ret;
}
long long mull(long long a, long long b) { return a * b % mod; }
long long mul[maxn << 2], vis[maxn << 2], laz1[maxn << 2], laz2[maxn << 2];
int a[maxn];
void pushup(int rt) {
  mul[rt] = mull(mul[(rt << 1)], mul[(rt << 1 | 1)]);
  vis[rt] = vis[(rt << 1)] | vis[(rt << 1 | 1)];
  return;
}
void pushdown(int rt, int llen, int rlen) {
  mul[(rt << 1)] = mull(mul[(rt << 1)], pow_(laz1[rt], llen, mod));
  mul[(rt << 1 | 1)] = mull(mul[(rt << 1 | 1)], pow_(laz1[rt], rlen, mod));
  laz1[(rt << 1)] = mull(laz1[(rt << 1)], laz1[rt]);
  laz1[(rt << 1 | 1)] = mull(laz1[(rt << 1 | 1)], laz1[rt]);
  laz1[rt] = 1;
  vis[(rt << 1)] |= laz2[rt];
  vis[(rt << 1 | 1)] |= laz2[rt];
  laz2[(rt << 1)] |= laz2[rt];
  laz2[(rt << 1 | 1)] |= laz2[rt];
  laz2[rt] = 0;
  return;
}
inline void build(int rt, int l, int r) {
  mul[rt] = vis[rt] = laz2[rt] = 0;
  laz1[rt] = 1;
  if (l == r) {
    mul[rt] = a[l];
    vis[rt] = find_prime(mul[rt]);
    return;
  }
  build((rt << 1), l, ((l + r) >> 1));
  build((rt << 1 | 1), ((l + r) >> 1) + 1, r);
  pushup(rt);
  return;
}
inline void update(int rt, int l, int r, int L, int R, int x, long long vx) {
  if (L <= l && r <= R) {
    mul[rt] = mull(mul[rt], pow_(x, r - l + 1, mod));
    vis[rt] |= vx;
    laz1[rt] = mull(laz1[rt], x);
    laz2[rt] |= vx;
    return;
  }
  if (laz1[rt] > 1) pushdown(rt, ((l + r) >> 1) - l + 1, r - ((l + r) >> 1));
  if (laz2[rt]) pushdown(rt, ((l + r) >> 1) - l + 1, r - ((l + r) >> 1));
  if (R <= ((l + r) >> 1))
    update((rt << 1), l, ((l + r) >> 1), L, R, x, vx);
  else if (L > ((l + r) >> 1))
    update((rt << 1 | 1), ((l + r) >> 1) + 1, r, L, R, x, vx);
  else
    update((rt << 1), l, ((l + r) >> 1), L, R, x, vx),
        update((rt << 1 | 1), ((l + r) >> 1) + 1, r, L, R, x, vx);
  pushup(rt);
  return;
}
inline pair<int, unsigned long long> query(int rt, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    return pair<int, unsigned long long>(mul[rt], vis[rt]);
  }
  if (laz1[rt] > 1) pushdown(rt, ((l + r) >> 1) - l + 1, r - ((l + r) >> 1));
  if (laz2[rt]) pushdown(rt, ((l + r) >> 1) - l + 1, r - ((l + r) >> 1));
  if (R <= ((l + r) >> 1)) return query((rt << 1), l, ((l + r) >> 1), L, R);
  if (L > ((l + r) >> 1))
    return query((rt << 1 | 1), ((l + r) >> 1) + 1, r, L, R);
  pair<int, unsigned long long> a = query((rt << 1), l, ((l + r) >> 1), L, R);
  pair<int, unsigned long long> b =
      query((rt << 1 | 1), ((l + r) >> 1) + 1, r, L, R);
  return pair<int, unsigned long long>(mull(a.first, b.first),
                                       (a.second | b.second));
}
long long phi(long long mul, unsigned long long vis) {
  for (int i = 0; i <= tot; ++i)
    if ((vis >> i) & 1) mul = mull(mul, mull(prime[i] - 1, inv_prime[i]));
  return mul;
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) a[i] = read();
  init();
  build(1, 1, n);
  char s[20];
  int l, r, x;
  while (q--) {
    scanf("%s", s);
    l = read();
    r = read();
    if (s[0] == 'M') {
      x = read();
      update(1, 1, n, l, r, x, find_prime(x));
    } else {
      pair<int, unsigned long long> tmp = query(1, 1, n, l, r);
      printf("%lld\n", phi(tmp.first, tmp.second));
    }
  }
  return 0;
}
