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 MAXN = 400005;
const int MAXV = 305;
const long long MOD = 1000000007;
int n, q, tot;
int a[MAXN];
int prime[MAXV];
long long inv[MAXV];
long long laz1[MAXN << 2];
long long mul[MAXN << 2];
unsigned long long mask[MAXN];
unsigned long long laz2[MAXN << 2];
unsigned long long info[MAXN << 2];
bool mark[MAXV];
char s[10];
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) (res *= a) %= MOD;
    (a *= a) %= MOD;
    b >>= 1;
  }
  return res;
}
void init() {
  for (int i = 2; i <= 300; i++) {
    if (!mark[i]) {
      inv[tot] = power(i, MOD - 2);
      prime[tot++] = i;
    }
    for (int j = 0; j < tot && i * prime[j] <= 300; j++) {
      mark[i * prime[j]] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
void pushup(int o) {
  mul[o] = mul[o << 1] * mul[o << 1 | 1] % MOD;
  info[o] = info[o << 1] | info[o << 1 | 1];
}
void mdf1(int o, int l, int r, long long v) {
  (mul[o] *= power(v, r - l + 1)) %= MOD;
  (laz1[o] *= v) %= MOD;
}
void mdf2(int o, unsigned long long v) {
  info[o] |= v;
  laz2[o] |= v;
}
void pushdown(int o, int l, int r) {
  int mid = (l + r) >> 1;
  if (laz1[o] != 1) {
    mdf1(o << 1, l, mid, laz1[o]);
    mdf1(o << 1 | 1, mid + 1, r, laz1[o]);
    laz1[o] = 1;
  }
  if (laz2[o]) {
    mdf2(o << 1, laz2[o]);
    mdf2(o << 1 | 1, laz2[o]);
    laz2[o] = 0;
  }
}
void buildtree(int o, int l, int r) {
  laz1[o] = 1;
  if (l == r) {
    mul[o] = a[l];
    info[o] = mask[l];
    return;
  }
  int mid = (l + r) >> 1;
  buildtree(o << 1, l, mid);
  buildtree(o << 1 | 1, mid + 1, r);
  pushup(o);
}
void modify(int o, int l, int r, int x, int y, long long v,
            unsigned long long V) {
  if (l >= x && r <= y) {
    mdf1(o, l, r, v);
    mdf2(o, V);
    return;
  }
  pushdown(o, l, r);
  int mid = (l + r) >> 1;
  if (mid >= x) modify(o << 1, l, mid, x, y, v, V);
  if (mid + 1 <= y) modify(o << 1 | 1, mid + 1, r, x, y, v, V);
  pushup(o);
}
long long query1(int o, int l, int r, int x, int y) {
  if (l >= x && r <= y) return mul[o];
  pushdown(o, l, r);
  int mid = (l + r) >> 1;
  if (mid + 1 > y) return query1(o << 1, l, mid, x, y);
  if (mid < x) return query1(o << 1 | 1, mid + 1, r, x, y);
  return query1(o << 1, l, mid, x, y) * query1(o << 1 | 1, mid + 1, r, x, y) %
         MOD;
}
unsigned long long query2(int o, int l, int r, int x, int y) {
  if (l >= x && r <= y) return info[o];
  pushdown(o, l, r);
  int mid = (l + r) >> 1;
  if (mid + 1 > y) return query2(o << 1, l, mid, x, y);
  if (mid < x) return query2(o << 1 | 1, mid + 1, r, x, y);
  return query2(o << 1, l, mid, x, y) | query2(o << 1 | 1, mid + 1, r, x, y);
}
int main() {
  init();
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    for (int j = 0; j < tot; j++)
      if (a[i] % prime[j] == 0) mask[i] |= (1ull << j);
  }
  buildtree(1, 1, n);
  for (int l, r, v, i = 1; i <= q; i++) {
    scanf("%s", s);
    if (s[0] == 'M') {
      scanf("%d%d%d", &l, &r, &v);
      unsigned long long V = 0;
      for (int j = 0; j < tot; j++)
        if (v % prime[j] == 0) V |= (1ull << j);
      modify(1, 1, n, l, r, v, V);
    } else {
      scanf("%d%d", &l, &r);
      long long res1 = query1(1, 1, n, l, r), res2 = query2(1, 1, n, l, r);
      for (int j = 0; j < tot; j++)
        if (res2 >> j & 1) (res1 *= (prime[j] - 1) * inv[j] % MOD) %= MOD;
      printf("%d\n", (int)res1);
    }
  }
  return 0;
}
