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 N = 400050;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
int n, q;
long long pri[300], inv[300];
int tot, id[300];
long long a[N];
bool vis[300];
vector<int> f[305];
inline long long mi(long long a, long long b) {
  a %= mod;
  long long ret = 1;
  while (b) {
    if (b & 1) ret *= a, ret %= mod;
    a *= a, a %= mod;
    b >>= 1;
  }
  return ret;
}
void shaipri() {
  for (int i = 2; i <= 300; ++i) {
    if (!vis[i]) vis[i] = 1, pri[++tot] = i, id[i] = tot;
    for (int j = 1; j <= tot && i * pri[j] <= 300; ++j) {
      vis[i * pri[j]] = 1;
      if (i % pri[j] == 0) break;
    }
  }
}
inline void fenjie(int x) {
  int now = x;
  for (int i = 1; i <= tot; ++i) {
    if (x % pri[i] == 0) {
      f[now].push_back(i);
      while (x % pri[i] == 0) x /= pri[i];
    }
  }
}
struct segtree {
  int l, r;
  long long lazy, v;
  long long state, lazystate;
} t[N << 2];
inline void pushup(int id) {
  t[id].v = (t[id << 1].v * t[id << 1 | 1].v) % mod;
  t[id].state = (t[id << 1].state | t[id << 1 | 1].state);
}
inline void pushdown(int id) {
  if (t[id].lazy != 1) {
    t[id << 1].v *= mi(t[id].lazy, (t[id << 1].r - t[id << 1].l + 1LL)),
        t[id << 1].v %= mod;
    t[id << 1 | 1].v *=
        mi(t[id].lazy, (t[id << 1 | 1].r - t[id << 1 | 1].l + 1LL)),
        t[id << 1 | 1].v %= mod;
    t[id << 1].lazy *= t[id].lazy, t[id << 1].lazy %= mod;
    t[id << 1 | 1].lazy *= t[id].lazy, t[id << 1 | 1].lazy %= mod;
    t[id << 1].state |= t[id].lazystate;
    t[id << 1 | 1].state |= t[id].lazystate;
    t[id << 1].lazystate |= t[id].lazystate;
    t[id << 1 | 1].lazystate |= t[id].lazystate;
    t[id].lazy = 1;
    t[id].lazystate = 0;
  }
}
void build(int l, int r, int id) {
  t[id].lazy = 1;
  t[id].l = l, t[id].r = r;
  if (l == r) {
    t[id].v = a[l];
    for (auto i : f[a[l]]) t[id].state |= (1LL << (i - 1));
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, id << 1);
  build(mid + 1, r, id << 1 | 1);
  pushup(id);
}
void change(int id, int L, int R, long long x) {
  int l = t[id].l, r = t[id].r;
  if (l >= L && R >= r) {
    t[id].v *= mi(x, r - l + 1), t[id].v %= mod;
    t[id].lazy *= x, t[id].lazy %= mod;
    for (auto i : f[x]) {
      t[id].state |= (1LL << (i - 1));
      t[id].lazystate |= (1LL << (i - 1));
    }
    return;
  }
  pushdown(id);
  int mid = (l + r) >> 1;
  if (R <= mid)
    change(id << 1, L, R, x);
  else if (L > mid)
    change(id << 1 | 1, L, R, x);
  else {
    change(id << 1, L, mid, x);
    change(id << 1 | 1, mid + 1, R, x);
  }
  pushup(id);
}
long long querystate(int id, int L, int R) {
  int l = t[id].l, r = t[id].r;
  if (l >= L && r <= R) return t[id].state;
  pushdown(id);
  int mid = (l + r) >> 1;
  if (R <= mid)
    return querystate(id << 1, L, R);
  else if (L > mid)
    return querystate(id << 1 | 1, L, R);
  else
    return (querystate(id << 1, L, mid) | querystate(id << 1 | 1, mid + 1, R));
}
long long queryprod(int id, int L, int R) {
  int l = t[id].l, r = t[id].r;
  if (l >= L && r <= R) return t[id].v;
  pushdown(id);
  int mid = (l + r) >> 1;
  if (R <= mid)
    return queryprod(id << 1, L, R);
  else if (L > mid)
    return queryprod(id << 1 | 1, L, R);
  else
    return (queryprod(id << 1, L, mid) * queryprod(id << 1 | 1, mid + 1, R)) %
           mod;
}
void Init() {
  shaipri();
  for (int i = 1; i <= 300; ++i) fenjie(i);
  for (int i = 1; i <= tot; ++i) inv[i] = mi(pri[i], mod - 2);
}
char op[10];
int main() {
  Init();
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  build(1, n, 1);
  while (q--) {
    scanf("%s", op);
    int l, r;
    scanf("%d%d", &l, &r);
    if (op[0] == 'M') {
      long long x;
      scanf("%lld", &x);
      change(1, l, r, x);
    } else {
      long long state = querystate(1, l, r);
      long long x = queryprod(1, l, r);
      for (int i = 1; i <= tot; ++i) {
        if (state & (1LL << (i - 1))) x = x * (pri[i] - 1) % mod * inv[i] % mod;
      }
      printf("%lld\n", x);
    }
  }
  return 0;
}
