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 long long MOD = 1000000007;
const int maxn = 400000 + 10;
int cnt, n, q, x, l, r;
int sum[63][maxn], ssum[63][maxn];
long long inv[301], mult[301];
int prime[301];
bool vis[301];
vector<int> fac;
long long num[maxn << 2], lazy[maxn << 2];
char cmd[20];
int Index_of_prime[301];
void Prime(int n) {
  for (int i = 2; i <= n; ++i) {
    if (!vis[i]) {
      Index_of_prime[i] = cnt;
      prime[cnt++] = i;
    }
    for (int j = 0; j < cnt && i <= n / prime[j]; ++j) {
      int k = i * prime[j];
      vis[k] = true;
      if (i % prime[j] == 0) {
        break;
      }
    }
  }
}
void get_fac(int n, vector<int> &fac) {
  fac.clear();
  for (int i = 0; i < cnt && prime[i] <= n / prime[i]; ++i) {
    if (n % prime[i] == 0) {
      fac.push_back(prime[i]);
      while (n % prime[i] == 0) {
        n /= prime[i];
      }
    }
  }
  if (n != 1) {
    fac.push_back(n);
  }
}
void Prepare_C() {
  inv[1] = 1;
  for (int i = 2; i <= 300; ++i) {
    inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
  }
}
int lowbit(int x) { return x & (-x); }
void update(int *sum, int *ssum, int Index, int x) {
  int tmp = Index;
  while (tmp <= n) {
    sum[tmp] += x;
    ssum[tmp] += (long long)x * Index;
    tmp += lowbit(tmp);
  }
}
long long query(int *sum, int *ssum, int Index) {
  long long ret = 0;
  int tmp = Index;
  while (tmp != 0) {
    ret += sum[tmp] * (Index + 1) - ssum[tmp];
    tmp -= lowbit(tmp);
  }
  return ret;
}
void push_up(int rt) { num[rt] = num[rt << 1] * num[rt << 1 | 1] % MOD; }
long long fast_pow(long long res, long long n) {
  long long ans;
  for (ans = 1; n != 0; n >>= 1) {
    if ((n & 1) == 1) {
      ans = ans * res % MOD;
    }
    res = res * res % MOD;
  }
  return ans;
}
void push_down(int rt, int len) {
  if (lazy[rt] != 1) {
    lazy[rt << 1] = lazy[rt << 1] * lazy[rt] % MOD;
    lazy[rt << 1 | 1] = lazy[rt << 1 | 1] * lazy[rt] % MOD;
    num[rt << 1] = fast_pow(lazy[rt], len - (len >> 1)) * num[rt << 1] % MOD;
    num[rt << 1 | 1] = fast_pow(lazy[rt], len >> 1) * num[rt << 1 | 1] % MOD;
    lazy[rt] = 1;
  }
}
void build(int l, int r, int rt) {
  lazy[rt] = 1;
  num[rt] = 1;
  if (l == r) {
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
}
void update(int L, int R, long long tmp, int l, int r, int rt) {
  if (L <= l && r <= R) {
    lazy[rt] = lazy[rt] * tmp % MOD;
    num[rt] = num[rt] * fast_pow(tmp, r - l + 1) % MOD;
    return;
  }
  push_down(rt, r - l + 1);
  int m = (l + r) >> 1;
  if (L <= m) {
    update(L, R, tmp, l, m, rt << 1);
  }
  if (m < R) {
    update(L, R, tmp, m + 1, r, rt << 1 | 1);
  }
  push_up(rt);
}
long long query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return num[rt];
  }
  push_down(rt, r - l + 1);
  int m = (l + r) >> 1;
  long long ret = 1;
  if (L <= m) {
    ret = ret * query(L, R, l, m, rt << 1) % MOD;
  }
  if (m < R) {
    ret = ret * query(L, R, m + 1, r, rt << 1 | 1) % MOD;
  }
  return ret;
}
void update(int l, int r, int x) {
  update(l, r, x, 1, n, 1);
  get_fac(x, fac);
  int len = fac.size();
  for (int i = 0; i < len; ++i) {
    update(sum[Index_of_prime[fac[i]]], ssum[Index_of_prime[fac[i]]], l, 1);
    update(sum[Index_of_prime[fac[i]]], ssum[Index_of_prime[fac[i]]], r + 1,
           -1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  Prepare_C();
  Prime(300);
  for (int i = 1; i <= 300; ++i) {
    mult[i] = (i - 1) * inv[i] % MOD;
  }
  while (scanf("%d%d", &n, &q) != EOF) {
    for (int i = 0; i <= 62; ++i) {
      memset(sum[i] + 1, 0, sizeof(int) * n);
    }
    build(1, n, 1);
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &x);
      update(i, i, x);
    }
    while (q--) {
      scanf("%s", cmd);
      if (cmd[0] == 'M') {
        scanf("%d%d%d", &l, &r, &x);
        update(l, r, x);
      } else {
        scanf("%d%d", &l, &r);
        long long ans = query(l, r, 1, n, 1);
        for (int i = 0; i <= 62; ++i) {
          if (query(sum[i], ssum[i], l - 1) != query(sum[i], ssum[i], r)) {
            ans = ans * mult[prime[i]] % MOD;
          }
        }
        printf("%I64d\n", ans);
      }
    }
  }
  return 0;
}
