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 long long read() {
  char ch = 0;
  long long x = 0, flag = 1;
  while (!isdigit(ch)) {
    ch = getchar();
    if (ch == '-') flag = -1;
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * flag;
}
const long long mo = 1e9 + 7;
long long a[1000] = {0,   2,   3,   5,   7,   11,  13,  17,  19,  23,  29,
                     31,  37,  41,  43,  47,  53,  59,  61,  67,  71,  73,
                     79,  83,  89,  97,  101, 103, 107, 109, 113, 127, 131,
                     137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191,
                     193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251,
                     257, 263, 269, 271, 277, 281, 283, 293};
long long inv[1000];
long long ksm(long long x, long long k) {
  long long ans = 1;
  while (k) {
    if (k & 1) ans = ans * x % mo;
    k >>= 1;
    x = x * x % mo;
  }
  return ans;
}
struct Segment_Tree {
  long long add1[660000 * 4], add2[660000 * 4], ans1[660000 * 4],
      ans2[660000 * 4];
  void pushup(long long o) {
    ans1[o] = ans1[o << 1] * ans1[o << 1 | 1] % mo;
    ans2[o] = ans2[o << 1] | ans2[o << 1 | 1];
  }
  void pushdown(long long o, long long l, long long r) {
    long long x = ksm(add1[o], ((l + r) >> 1) - l + 1),
              y = ksm(add1[o], r - ((l + r) >> 1));
    add1[o << 1] = add1[o << 1] * add1[o] % mo;
    add1[o << 1 | 1] = add1[o << 1 | 1] * add1[o] % mo;
    ans1[o << 1] = ans1[o << 1] * x % mo;
    ans1[o << 1 | 1] = ans1[o << 1 | 1] * y % mo;
    add1[o] = 1;
    add2[o << 1] = add2[o << 1] | add2[o];
    add2[o << 1 | 1] = add2[o << 1 | 1] | add2[o];
    ans2[o << 1] = ans2[o << 1] | add2[o];
    ans2[o << 1 | 1] = ans2[o << 1 | 1] | add2[o];
    add2[o] = 0;
  }
  void build(long long o, long long l, long long r) {
    add1[o] = 1;
    add2[o] = 0;
    if (l == r) {
      ans1[o] = read();
      ans2[o] = 0;
      for (long long k = 1; k <= 62; k++)
        if (ans1[o] % a[k] == 0) ans2[o] |= 1ll << (k - 1);
      return;
    }
    build(o << 1, l, ((l + r) >> 1));
    build(o << 1 | 1, ((l + r) >> 1) + 1, r);
    pushup(o);
  }
  void optset(long long o, long long l, long long r, long long ql, long long qr,
              long long x, long long p) {
    if (ql <= l && r <= qr) {
      ans1[o] = ans1[o] * ksm(x, r - l + 1) % mo;
      ans2[o] = ans2[o] | p;
      add1[o] = add1[o] * x % mo;
      add2[o] = add2[o] | p;
      return;
    }
    pushdown(o, l, r);
    if (ql <= ((l + r) >> 1)) optset(o << 1, l, ((l + r) >> 1), ql, qr, x, p);
    if (qr > ((l + r) >> 1))
      optset(o << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr, x, p);
    pushup(o);
  }
  long long query1(long long o, long long l, long long r, long long ql,
                   long long qr) {
    if (ql <= l && r <= qr) return ans1[o];
    pushdown(o, l, r);
    long long ans = 1;
    if (ql <= ((l + r) >> 1))
      ans = ans * query1(o << 1, l, ((l + r) >> 1), ql, qr) % mo;
    if (qr > ((l + r) >> 1))
      ans = ans * query1(o << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr) % mo;
    return ans;
  }
  long long query2(long long o, long long l, long long r, long long ql,
                   long long qr) {
    if (ql <= l && r <= qr) return ans2[o];
    pushdown(o, l, r);
    long long ans = 0;
    if (ql <= ((l + r) >> 1))
      ans = ans | query2(o << 1, l, ((l + r) >> 1), ql, qr);
    if (qr > ((l + r) >> 1))
      ans = ans | query2(o << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr);
    return ans;
  }
} T;
int main() {
  long long n = read(), m = read();
  for (long long i = 1; i <= 70; i++) inv[i] = ksm(a[i], mo - 2) % mo;
  T.build(1, 1, n);
  for (long long i = 1; i <= m; i++) {
    char ch[20];
    scanf("%s", ch);
    long long l = read(), r = read();
    if (ch[0] == 'M') {
      long long x = read() % mo, p = 0;
      for (long long k = 1; k <= 62; k++)
        if (x % a[k] == 0) p |= 1ll << (k - 1);
      T.optset(1, 1, n, l, r, x, p);
    } else {
      long long ans = T.query1(1, 1, n, l, r) % mo;
      long long y = T.query2(1, 1, n, l, r);
      for (long long k = 1; k <= 62; k++)
        if ((1ll << (k - 1)) & y) ans = ans * (a[k] - 1) % mo * inv[k] % mo;
      printf("%lld\n", ans);
    }
  }
  return 0;
}
