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;
inline void read(int &x) {
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
}
void print(int x) {
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
inline int power(int a, int t) {
  int res = 1;
  while (t) {
    if (t & 1) res = (long long)res * a % 1000000007;
    a = (long long)a * a % 1000000007;
    t >>= 1;
  }
  return res;
}
inline int dec(int a, int b) { return a < b ? a - b + 1000000007 : a - b; }
int pr[303], a[400003], tag1[400003 << 2], mul[400003 << 2], inv[303];
bool vis[303];
unsigned long long st[303], s[400003 << 2], tag2[400003 << 2];
char str[233];
int n, q, cnt;
inline void sieve(int n) {
  for (register int i = 2; i <= n; ++i) {
    if (!vis[i]) pr[++cnt] = i;
    for (register int j = 1; j <= cnt; ++j) {
      if (i * pr[j] > n) break;
      vis[i * pr[j]] = true;
      if (i % pr[j] == 0) break;
    }
  }
  inv[1] = 1;
  for (register int i = 2; i <= n; ++i)
    inv[i] = (long long)(1000000007 - 1000000007 / i) * inv[1000000007 % i] %
             1000000007;
}
void pushup(int u) {
  s[u] = s[(u << 1)] | s[(u << 1 | 1)];
  mul[u] = (long long)mul[(u << 1)] * mul[(u << 1 | 1)] % 1000000007;
}
inline void pushdown(int u, int l, int r) {
  if (tag1[u] != 1) {
    tag1[(u << 1)] = (long long)tag1[(u << 1)] * tag1[u] % 1000000007;
    tag1[(u << 1 | 1)] = (long long)tag1[(u << 1 | 1)] * tag1[u] % 1000000007;
    mul[(u << 1)] = (long long)mul[(u << 1)] *
                    power(tag1[u], ((l + r) >> 1) - l + 1) % 1000000007;
    mul[(u << 1 | 1)] = (long long)mul[(u << 1 | 1)] *
                        power(tag1[u], r - ((l + r) >> 1)) % 1000000007;
    tag1[u] = 1;
  }
  if (tag2[u]) {
    tag2[(u << 1)] |= tag2[u], tag2[(u << 1 | 1)] |= tag2[u];
    s[(u << 1)] |= tag2[u], s[(u << 1 | 1)] |= tag2[u];
    tag2[u] = 0;
  }
}
void build(int l, int r, int u) {
  if (l == r) {
    s[u] = st[a[l]];
    mul[u] = a[l];
    return;
  }
  build(l, ((l + r) >> 1), (u << 1));
  build(((l + r) >> 1) + 1, r, (u << 1 | 1));
  pushup(u);
}
void modify(int nl, int nr, int l, int r, int u, int k) {
  if (nl <= l && r <= nr) {
    tag1[u] = (long long)tag1[u] * k % 1000000007;
    tag2[u] |= st[k];
    s[u] |= st[k];
    mul[u] = (long long)mul[u] * power(k, r - l + 1) % 1000000007;
    return;
  }
  pushdown(u, l, r);
  if (nl <= ((l + r) >> 1)) modify(nl, nr, l, ((l + r) >> 1), (u << 1), k);
  if (nr > ((l + r) >> 1))
    modify(nl, nr, ((l + r) >> 1) + 1, r, (u << 1 | 1), k);
  pushup(u);
}
int qmul(int nl, int nr, int l, int r, int u) {
  if (nl <= l && r <= nr) return mul[u];
  pushdown(u, l, r);
  int res = 1;
  if (nl <= ((l + r) >> 1))
    res =
        (long long)res * qmul(nl, nr, l, ((l + r) >> 1), (u << 1)) % 1000000007;
  if (nr > ((l + r) >> 1))
    res = (long long)res * qmul(nl, nr, ((l + r) >> 1) + 1, r, (u << 1 | 1)) %
          1000000007;
  return res;
}
unsigned long long qset(int nl, int nr, int l, int r, int u) {
  if (nl <= l && r <= nr) return s[u];
  pushdown(u, l, r);
  unsigned long long res = 0;
  if (nl <= ((l + r) >> 1)) res |= qset(nl, nr, l, ((l + r) >> 1), (u << 1));
  if (nr > ((l + r) >> 1))
    res |= qset(nl, nr, ((l + r) >> 1) + 1, r, (u << 1 | 1));
  return res;
}
int main() {
  for (register int i = 0; i < (400003 << 2); ++i) tag1[i] = 1;
  int l, r, k, pt, ans;
  unsigned long long tmp;
  sieve(300);
  read(n), read(q);
  for (register int i = 1; i <= n; ++i) read(a[i]);
  for (register int i = 1; i <= 300; ++i)
    for (register int j = 1; j <= cnt; ++j)
      if (i % pr[j] == 0) st[i] |= 1ull << j;
  build(1, n, 1);
  while (q--) {
    pt = 0;
    char c = getchar();
    while (c < 'A' || c > 'Z') c = getchar();
    while (c >= 'A' && c <= 'Z') {
      str[++pt] = c;
      c = getchar();
    }
    read(l), read(r);
    if (str[1] == 'T') {
      ans = qmul(l, r, 1, n, 1);
      tmp = qset(l, r, 1, n, 1);
      for (register int i = 1; i <= cnt; ++i) {
        if (!((tmp >> i) & 1)) continue;
        ans = (long long)ans * dec(1, inv[pr[i]]) % 1000000007;
      }
      print(ans);
      putchar('\n');
    } else {
      read(k);
      modify(l, r, 1, n, 1, k);
    }
  }
  return 0;
}
