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;
int T[1050000], Lazy[1050000];
long long Mask[1050000], LazyMask[1050000];
bool p[301];
int pos, out;
int N, Q, Start, End, primes[63], inverse[63], TotalPrimes = -1, Pos, Val,
                                               ans[400005], v[400005], idx;
long long mask, M[301];
char s, f[1 << 17], Out[1 << 17], str[10];
inline void Write_Ch(char ch) {
  Out[out++] = ch;
  if (out == 1 << 17) fwrite(Out, 1 << 17, 1, stdout), out = 0;
}
inline void Write_Int(int nr) {
  int x = 0;
  do {
    str[x++] = nr % 10 + '0';
    nr /= 10;
  } while (nr);
  while (x > 0) Write_Ch(str[--x]);
}
inline void Read(int &nr) {
  nr = 0;
  while (f[pos] < '0' || f[pos] > '9') {
    pos++;
    if (pos == 1 << 17) fread(f, 1 << 17, 1, stdin), pos = 0;
  }
  while (f[pos] >= '0' && f[pos] <= '9') {
    nr = 10 * nr + f[pos++] - '0';
    if (pos == 1 << 17) fread(f, 1 << 17, 1, stdin), pos = 0;
  }
}
inline void ReadStr(char &s) {
  s = 0;
  while (f[pos] < 'A' || f[pos] > 'Z') {
    pos++;
    if (pos == 1 << 17) fread(f, 1 << 17, 1, stdin), pos = 0;
  }
  while (f[pos] >= 'A' && f[pos] <= 'Z') {
    if (s == 0) s = f[pos];
    pos++;
    if (pos == 1 << 17) fread(f, 1 << 17, 1, stdin), pos = 0;
  }
}
inline int LogPow(int base, int exp) {
  if (base == 1) return 1;
  int act = 1;
  for (int i = 0; i < 30; i++) {
    if (exp & (1 << i)) act = 1LL * act * base % 1000000007;
    base = 1LL * base * base % 1000000007;
  }
  return act;
}
inline void precalc() {
  for (int i = 1; i < 1050000; i++) T[i] = Lazy[i] = 1;
  for (int i = 2; i <= 300; i++) {
    if (!p[i]) {
      primes[++TotalPrimes] = i;
      inverse[TotalPrimes] = LogPow(i, 1000000007 - 2);
      for (int j = i; j <= 300; j += i) p[j] = 1, M[j] += (1LL << TotalPrimes);
    }
  }
}
inline void Propagate(int node, int s, int e) {
  T[node] = 1LL * T[node] * LogPow(Lazy[node], e - s + 1) % 1000000007;
  if (s != e) {
    Lazy[node << 1] = 1LL * Lazy[node << 1] * Lazy[node] % 1000000007;
    Lazy[(node << 1) + 1] =
        1LL * Lazy[(node << 1) + 1] * Lazy[node] % 1000000007;
  }
  Lazy[node] = 1;
  Mask[node] |= LazyMask[node];
  if (s != e) {
    LazyMask[node << 1] |= LazyMask[node];
    LazyMask[(node << 1) + 1] |= LazyMask[node];
  }
  LazyMask[node] = 0;
}
void DFS(int node, int s, int e) {
  if (s == e) {
    T[node] = v[s];
    Mask[node] = M[v[s]];
  } else {
    int mid = (s + e) >> 1;
    DFS(node << 1, s, mid);
    DFS((node << 1) + 1, mid + 1, e);
    T[node] = 1LL * T[node << 1] * T[(node << 1) + 1] % 1000000007;
    Mask[node] |= Mask[node << 1] | Mask[(node << 1) + 1];
  }
}
void Update(int node, int s, int e) {
  Propagate(node, s, e);
  if (Start <= s && e <= End) {
    Lazy[node] = 1LL * Lazy[node] * Val % 1000000007;
    LazyMask[node] |= M[Val];
  } else {
    int mid = (s + e) >> 1;
    if (Start <= mid) Update(node << 1, s, mid);
    if (End > mid) Update((node << 1) + 1, mid + 1, e);
    T[node] = 1LL * T[node << 1] * T[(node << 1) + 1] % 1000000007;
    T[node] = 1LL * T[node] * LogPow(Lazy[node << 1], mid - s + 1) % 1000000007;
    T[node] =
        1LL * T[node] * LogPow(Lazy[(node << 1) + 1], e - mid) % 1000000007;
    Mask[node] |= LazyMask[node << 1] | LazyMask[(node << 1) + 1] |
                  Mask[node << 1] | Mask[(node << 1) + 1];
  }
}
void Query(int node, int s, int e) {
  Propagate(node, s, e);
  if (Start <= s && e <= End) {
    Val = 1LL * Val * T[node] % 1000000007;
    mask |= Mask[node];
  } else {
    int mid = (s + e) >> 1;
    if (Start <= mid) Query(node << 1, s, mid);
    if (End > mid) Query((node << 1) + 1, mid + 1, e);
  }
}
int main() {
  fread(f, 1, 1 << 17, stdin);
  precalc();
  Read(N), Read(Q);
  for (int i = 1; i <= N; i++) Read(v[i]);
  DFS(1, 1, N);
  for (int i = 1; i <= Q; i++) {
    ReadStr(s);
    if (s == 'T') {
      Read(Start), Read(End);
      Val = 1;
      mask = 0;
      Query(1, 1, N);
      for (int j = 0; j <= TotalPrimes; j++)
        if (mask & (1LL << j))
          Val = 1LL * Val * inverse[j] % 1000000007 * (primes[j] - 1) %
                1000000007;
      Write_Int(Val), Write_Ch('\n');
    } else {
      Read(Start), Read(End), Read(Val);
      Update(1, 1, N);
    }
  }
  if (out > 0) fwrite(Out, 1, out, stdout);
  return 0;
}
