#include <bits/stdc++.h>
using namespace std;
const long long P = 1000000007;
const long long N = 400009;
long long Read() {
  long long ret = 0, nag = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') nag = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0')
    ret = (ret << 3) + (ret << 1) + c - '0', c = getchar();
  return ret * nag;
}
long long n, Q, st[N], isp[309], len;
long long sum[8 * N], jud[8 * N], tag1[8 * N], tag2[8 * N], pr[309], inv[309],
    ans1, ans2;
char opt[11];
long long Pow(long long x, long long y) {
  long long ret = 1;
  for (; y; y /= 2, x = x * x % P)
    if (y % 2) ret = ret * x % P;
  return ret;
}
void Prework() {
  for (long long i = 2; i <= 300; i++) {
    if (!isp[i]) pr[++len] = i;
    for (long long j = 1; j <= len && i * pr[j] <= 300; j++) {
      isp[i * pr[j]] = 1;
      if (i % pr[j] == 0) break;
    }
  }
  for (long long i = 1; i <= len; i++) inv[i] = Pow(pr[i], P - 2);
}
long long f(long long x) {
  long long ret = 0;
  for (long long i = 1; i <= len; i++)
    if (x % pr[i] == 0) ret |= (1ll << (i - 1));
  return ret;
}
inline void push_down(long long x, long long l, long long r) {
  long long mid = (l + r) >> 1;
  if (tag1[x] != 1) {
    tag1[(x << 1)] = tag1[(x << 1)] * tag1[x] % P,
               sum[(x << 1)] = sum[(x << 1)] * Pow(tag1[x], (mid - l + 1)) % P;
    tag1[((x << 1) | 1)] = tag1[((x << 1) | 1)] * tag1[x] % P,
                     sum[((x << 1) | 1)] =
                         sum[((x << 1) | 1)] * Pow(tag1[x], (r - mid)) % P;
    tag1[x] = 1;
  }
  if (tag2[x]) {
    tag2[(x << 1)] |= tag2[x], jud[(x << 1)] |= tag2[x];
    tag2[((x << 1) | 1)] |= tag2[x], jud[((x << 1) | 1)] |= tag2[x];
    tag2[x] = 0;
  }
}
inline void push_up(long long x) {
  jud[x] = jud[(x << 1)] | jud[((x << 1) | 1)];
  sum[x] = sum[(x << 1)] * sum[((x << 1) | 1)] % P;
}
void Build(long long x, long long l, long long r) {
  tag1[x] = 1;
  if (l == r) {
    sum[x] = st[l], jud[x] = f(st[l]);
    return;
  }
  long long mid = (l + r) >> 1;
  Build((x << 1), l, mid), Build(((x << 1) | 1), mid + 1, r);
  push_up(x);
}
void Modify(long long x, long long l, long long r, long long L, long long R,
            long long Val, long long Jud) {
  push_down(x, l, r);
  if (l == L && r == R) {
    sum[x] = sum[x] * Pow(Val, r - l + 1) % P, jud[x] |= Jud;
    tag1[x] = tag1[x] * Val % P, tag2[x] |= Jud;
    return;
  }
  long long mid = (l + r) >> 1;
  if (R <= mid)
    Modify((x << 1), l, mid, L, R, Val, Jud);
  else if (mid < L)
    Modify(((x << 1) | 1), mid + 1, r, L, R, Val, Jud);
  else
    Modify((x << 1), l, mid, L, mid, Val, Jud),
        Modify(((x << 1) | 1), mid + 1, r, mid + 1, R, Val, Jud);
  push_up(x);
}
void Query(long long x, long long l, long long r, long long L, long long R) {
  push_down(x, l, r);
  if (l == L && r == R) {
    ans1 = ans1 * sum[x] % P, ans2 |= jud[x];
    return;
  }
  long long mid = (l + r) >> 1;
  if (R <= mid)
    Query((x << 1), l, mid, L, R);
  else if (mid < L)
    Query(((x << 1) | 1), mid + 1, r, L, R);
  else
    Query((x << 1), l, mid, L, mid),
        Query(((x << 1) | 1), mid + 1, r, mid + 1, R);
}
int main() {
  Prework();
  n = Read(), Q = Read();
  for (long long i = 1; i <= n; i++) st[i] = Read();
  Build(1, 1, n);
  while (Q--) {
    scanf("%s", opt);
    if (opt[0] == 'T') {
      long long L = Read(), R = Read();
      ans1 = 1, ans2 = 0, Query(1, 1, n, L, R);
      for (long long i = 0; i < len; i++)
        if ((ans2 >> i) & 1) ans1 = ans1 * (pr[i + 1] - 1) % P * inv[i + 1] % P;
      printf("%lld\n", ans1);
    } else {
      long long L = Read(), R = Read(), x = Read();
      Modify(1, 1, n, L, R, x, f(x));
    }
  }
  return 0;
}

### Prompt

In Cpp, your task is to solve the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long P = 1000000007;
const long long N = 400009;
long long Read() {
  long long ret = 0, nag = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') nag = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0')
    ret = (ret << 3) + (ret << 1) + c - '0', c = getchar();
  return ret * nag;
}
long long n, Q, st[N], isp[309], len;
long long sum[8 * N], jud[8 * N], tag1[8 * N], tag2[8 * N], pr[309], inv[309],
    ans1, ans2;
char opt[11];
long long Pow(long long x, long long y) {
  long long ret = 1;
  for (; y; y /= 2, x = x * x % P)
    if (y % 2) ret = ret * x % P;
  return ret;
}
void Prework() {
  for (long long i = 2; i <= 300; i++) {
    if (!isp[i]) pr[++len] = i;
    for (long long j = 1; j <= len && i * pr[j] <= 300; j++) {
      isp[i * pr[j]] = 1;
      if (i % pr[j] == 0) break;
    }
  }
  for (long long i = 1; i <= len; i++) inv[i] = Pow(pr[i], P - 2);
}
long long f(long long x) {
  long long ret = 0;
  for (long long i = 1; i <= len; i++)
    if (x % pr[i] == 0) ret |= (1ll << (i - 1));
  return ret;
}
inline void push_down(long long x, long long l, long long r) {
  long long mid = (l + r) >> 1;
  if (tag1[x] != 1) {
    tag1[(x << 1)] = tag1[(x << 1)] * tag1[x] % P,
               sum[(x << 1)] = sum[(x << 1)] * Pow(tag1[x], (mid - l + 1)) % P;
    tag1[((x << 1) | 1)] = tag1[((x << 1) | 1)] * tag1[x] % P,
                     sum[((x << 1) | 1)] =
                         sum[((x << 1) | 1)] * Pow(tag1[x], (r - mid)) % P;
    tag1[x] = 1;
  }
  if (tag2[x]) {
    tag2[(x << 1)] |= tag2[x], jud[(x << 1)] |= tag2[x];
    tag2[((x << 1) | 1)] |= tag2[x], jud[((x << 1) | 1)] |= tag2[x];
    tag2[x] = 0;
  }
}
inline void push_up(long long x) {
  jud[x] = jud[(x << 1)] | jud[((x << 1) | 1)];
  sum[x] = sum[(x << 1)] * sum[((x << 1) | 1)] % P;
}
void Build(long long x, long long l, long long r) {
  tag1[x] = 1;
  if (l == r) {
    sum[x] = st[l], jud[x] = f(st[l]);
    return;
  }
  long long mid = (l + r) >> 1;
  Build((x << 1), l, mid), Build(((x << 1) | 1), mid + 1, r);
  push_up(x);
}
void Modify(long long x, long long l, long long r, long long L, long long R,
            long long Val, long long Jud) {
  push_down(x, l, r);
  if (l == L && r == R) {
    sum[x] = sum[x] * Pow(Val, r - l + 1) % P, jud[x] |= Jud;
    tag1[x] = tag1[x] * Val % P, tag2[x] |= Jud;
    return;
  }
  long long mid = (l + r) >> 1;
  if (R <= mid)
    Modify((x << 1), l, mid, L, R, Val, Jud);
  else if (mid < L)
    Modify(((x << 1) | 1), mid + 1, r, L, R, Val, Jud);
  else
    Modify((x << 1), l, mid, L, mid, Val, Jud),
        Modify(((x << 1) | 1), mid + 1, r, mid + 1, R, Val, Jud);
  push_up(x);
}
void Query(long long x, long long l, long long r, long long L, long long R) {
  push_down(x, l, r);
  if (l == L && r == R) {
    ans1 = ans1 * sum[x] % P, ans2 |= jud[x];
    return;
  }
  long long mid = (l + r) >> 1;
  if (R <= mid)
    Query((x << 1), l, mid, L, R);
  else if (mid < L)
    Query(((x << 1) | 1), mid + 1, r, L, R);
  else
    Query((x << 1), l, mid, L, mid),
        Query(((x << 1) | 1), mid + 1, r, mid + 1, R);
}
int main() {
  Prework();
  n = Read(), Q = Read();
  for (long long i = 1; i <= n; i++) st[i] = Read();
  Build(1, 1, n);
  while (Q--) {
    scanf("%s", opt);
    if (opt[0] == 'T') {
      long long L = Read(), R = Read();
      ans1 = 1, ans2 = 0, Query(1, 1, n, L, R);
      for (long long i = 0; i < len; i++)
        if ((ans2 >> i) & 1) ans1 = ans1 * (pr[i + 1] - 1) % P * inv[i + 1] % P;
      printf("%lld\n", ans1);
    } else {
      long long L = Read(), R = Read(), x = Read();
      Modify(1, 1, n, L, R, x, f(x));
    }
  }
  return 0;
}

```