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>
const int N = 4e5 + 5;
const int mod = 1e9 + 7;
const int pri[62] = {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};
const int inv[62] = {
    500000004, 333333336, 400000003, 142857144, 818181824, 153846155, 352941179,
    157894738, 739130440, 758620695, 129032259, 621621626, 658536590, 395348840,
    404255322, 56603774,  50847458,  688524595, 686567169, 98591550,  410958907,
    202531647, 84337350,  415730340, 268041239, 940594066, 572815538, 224299067,
    9174312,   893805316, 480314964, 190839696, 58394161,  604316551, 530201346,
    483443712, 343949047, 116564418, 5988024,   791907520, 435754193, 933701664,
    439790579, 694300523, 969543154, 507537692, 90047394,  125560539, 35242291,
    711790398, 90128756,  280334730, 406639007, 912350604, 70038911,  836501907,
    743494429, 450184505, 252707583, 718861215, 650176683, 522184304};
int n, q;
long long seg[N << 2], tag1[N << 2];
int mul[N << 2], tag2[N << 2];
int pow(int x, int p) {
  int ret = 1;
  for (; p; p >>= 1, x = 1LL * x * x % mod)
    if (p & 1) ret = 1LL * ret * x % mod;
  return ret;
}
void build(int p, int l, int r) {
  mul[p] = tag2[p] = 1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(p << 1, l, mid), build(p << 1 | 1, mid + 1, r);
}
void pushup(int p) {
  seg[p] = seg[p << 1] | seg[p << 1 | 1];
  mul[p] = 1LL * mul[p << 1] * mul[p << 1 | 1] % mod;
}
void upd1(int p, long long v) { seg[p] |= v, tag1[p] |= v; }
void upd2(int p, int l, int r, int k) {
  mul[p] = 1LL * mul[p] * pow(k, r - l + 1) % mod,
  tag2[p] = 1LL * tag2[p] * k % mod;
}
void pushdown(int p, int l, int r) {
  if (tag1[p]) upd1(p << 1, tag1[p]), upd1(p << 1 | 1, tag1[p]), tag1[p] = 0;
  if (tag2[p] > 1) {
    int mid = (l + r) >> 1;
    upd2(p << 1, l, mid, tag2[p]), upd2(p << 1 | 1, mid + 1, r, tag2[p]);
    tag2[p] = 1;
  }
}
void modify(int x, int y, int p, int l, int r, long long v, int k) {
  if (x <= l && r <= y) {
    upd1(p, v), upd2(p, l, r, k);
    return;
  }
  pushdown(p, l, r);
  int mid = (l + r) >> 1;
  if (x <= mid) modify(x, y, p << 1, l, mid, v, k);
  if (mid < y) modify(x, y, p << 1 | 1, mid + 1, r, v, k);
  pushup(p);
}
long long queryFac(int x, int y, int p, int l, int r) {
  if (x <= l && r <= y) return seg[p];
  pushdown(p, l, r);
  int mid = (l + r) >> 1;
  long long ans = 0;
  if (x <= mid) ans |= queryFac(x, y, p << 1, l, mid);
  if (mid < y) ans |= queryFac(x, y, p << 1 | 1, mid + 1, r);
  return ans;
}
int queryMul(int x, int y, int p, int l, int r) {
  if (x <= l && r <= y) return mul[p];
  pushdown(p, l, r);
  int mid = (l + r) >> 1, ans = 1;
  if (x <= mid) ans = 1LL * ans * queryMul(x, y, p << 1, l, mid) % mod;
  if (mid < y) ans = 1LL * ans * queryMul(x, y, p << 1 | 1, mid + 1, r) % mod;
  return ans;
}
void add(int x, int y, int k) {
  long long v = 0;
  for (int i = 0; i < 62; ++i)
    if (k % pri[i] == 0) v |= 1LL << i;
  modify(x, y, 1, 1, n, v, k);
}
int query(int x, int y) {
  long long v = queryFac(x, y, 1, 1, n);
  int ans = queryMul(x, y, 1, 1, n);
  for (int i = 0; i < 62; ++i)
    if (v & (1LL << i)) ans = 1LL * ans * inv[i] % mod * (pri[i] - 1) % mod;
  return ans;
}
int main() {
  scanf("%d%d", &n, &q);
  build(1, 1, n);
  for (int x, i = 1; i <= n; ++i) scanf("%d", &x), add(i, i, x);
  while (q--) {
    char s[20];
    int l, r;
    scanf("%s%d%d", s, &l, &r);
    if (s[0] == 'M') {
      int x;
      scanf("%d", &x);
      add(l, r, x);
    } else {
      printf("%d\n", query(l, r));
    }
  }
  return 0;
}
