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;
long long Pow[65] = {0}, MOD = 1000000007, Q = 0;
long long all[400005];
long long what[305];
long long which[305], now = 1;
long long have[305] = {0};
long long All[65];
char temp[15];
long long Pow2(long long N, long long M) {
  if (M == 0) return 1;
  long long t = Pow2(N, M / 2);
  t *= t;
  t %= MOD;
  if (M % 2) t *= N;
  t %= MOD;
  return t;
}
struct A {
  long long l, r;
  long long nxl;
  long long nxr;
  long long allt;
  long long Pt;
  long long P;
  long long all;
} Node[2000005];
void build(long long l, long long r, long long here) {
  long long i;
  Node[here].l = l;
  Node[here].r = r;
  Node[here].P = 0;
  Node[here].Pt = 0;
  Node[here].allt = 1;
  Node[here].all = 1;
  if (l == r) {
    Node[here].all = all[l];
    for (i = 0; i < 62; i++)
      if (all[l] % what[i] == 0) Node[here].P |= Pow[i];
    return;
  }
  Node[here].nxl = now++;
  Node[here].nxr = now++;
  build(l, (l + r) / 2, Node[here].nxl);
  build((l + r) / 2 + 1, r, Node[here].nxr);
  Node[here].all = Node[Node[here].nxl].all * Node[Node[here].nxr].all % MOD;
  Node[here].P = Node[Node[here].nxl].P | Node[Node[here].nxr].P;
}
void change(long long l, long long r, long long here, long long &t,
            long long &X) {
  long long i;
  Node[here].P |= X;
  Node[here].all *= Pow2(t, r - l + 1);
  Node[here].all %= MOD;
  if (l == Node[here].l && r == Node[here].r) {
    Node[here].allt *= t;
    Node[here].allt %= MOD;
    Node[here].Pt |= X;
    Node[here].P |= X;
    return;
  } else if (r <= (Node[here].l + Node[here].r) / 2)
    change(l, r, Node[here].nxl, t, X);
  else if (l > (Node[here].l + Node[here].r) / 2)
    change(l, r, Node[here].nxr, t, X);
  else {
    change(l, (Node[here].l + Node[here].r) / 2, Node[here].nxl, t, X);
    change((Node[here].l + Node[here].r) / 2 + 1, r, Node[here].nxr, t, X);
  }
}
pair<long long, long long> con(long long l, long long r, long long here) {
  if (l == Node[here].l && r == Node[here].r)
    return make_pair(Node[here].all, Node[here].P);
  Node[Node[here].nxl].allt *= Node[here].allt;
  Node[Node[here].nxl].allt %= MOD;
  Node[Node[here].nxl].all *= Pow2(
      Node[here].allt, Node[Node[here].nxl].r - Node[Node[here].nxl].l + 1);
  Node[Node[here].nxl].all %= MOD;
  Node[Node[here].nxl].Pt |= Node[here].Pt;
  Node[Node[here].nxl].P |= Node[here].Pt;
  Node[Node[here].nxr].allt *= Node[here].allt;
  Node[Node[here].nxr].allt %= MOD;
  Node[Node[here].nxr].all *= Pow2(
      Node[here].allt, Node[Node[here].nxr].r - Node[Node[here].nxr].l + 1);
  Node[Node[here].nxr].all %= MOD;
  Node[Node[here].nxr].Pt |= Node[here].Pt;
  Node[Node[here].nxr].P |= Node[here].Pt;
  Node[here].allt = 1;
  Node[here].Pt = 0;
  if (r <= (Node[here].l + Node[here].r) / 2)
    return con(l, r, Node[here].nxl);
  else if (l > (Node[here].l + Node[here].r) / 2)
    return con(l, r, Node[here].nxr);
  else {
    pair<long long, long long> t1 =
        con(l, (Node[here].l + Node[here].r) / 2, Node[here].nxl);
    pair<long long, long long> t2 =
        con((Node[here].l + Node[here].r) / 2 + 1, r, Node[here].nxr);
    return make_pair(t1.first * t2.first % MOD, t1.second | t2.second);
  }
}
int main() {
  long long N, M, i, j, l, r, t, X = 0;
  long long ans;
  Pow[0] = 1;
  for (i = 1; i < 65; i++) Pow[i] = Pow[i - 1] * 2;
  for (i = 2; i <= 300; i++) {
    if (!have[i]) {
      what[Q] = i;
      which[i] = Q;
      All[Q] = Pow2(i, MOD - 2);
      All[Q] *= (i - 1);
      All[Q] %= MOD;
      Q++;
      for (j = i * i; j <= 300; j += i) have[j] = 1;
    }
  }
  scanf("%lld %lld", &N, &M);
  for (i = 0; i < N; i++) scanf("%lld", &all[i]);
  build(0, N - 1, 0);
  while (M--) {
    scanf("%s", temp);
    if (temp[0] == 'T') {
      ans = 1;
      scanf("%lld %lld", &l, &r);
      l--;
      r--;
      pair<long long, long long> T;
      T = con(l, r, 0);
      ans = T.first;
      for (i = 0; i < Q; i++) {
        if (T.second & Pow[i]) {
          ans *= All[i];
          ans %= MOD;
        }
      }
      printf("%lld\n", ans);
    } else {
      scanf("%lld %lld %lld", &l, &r, &t);
      X = 0;
      for (i = 0; i < 62; i++)
        if (t % what[i] == 0) X |= Pow[i];
      l--;
      r--;
      change(l, r, 0, t, X);
    }
  }
  return 0;
}
