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;
const long long MOD = (long long)1e9 + 7;
long long mask[305], value[305], a[400005];
int number[305], prime[305];
pair<long long, long long> proiz[2000005], bitmask[2000005];
long long binpow(long long v, long long step) {
  if (step == 0) return 1;
  if (step % 2 == 0) {
    long long t = binpow(v, step / 2);
    return t * t % MOD;
  } else
    return v * binpow(v, step - 1) % MOD;
}
long long revers(long long v) { return binpow(v, MOD - 2); }
bool prost(int v) {
  if (v == 1) return false;
  for (int i = 2; i * i <= v; i++)
    if (v % i == 0) return false;
  return true;
}
void build(int v, int lef, int rig) {
  if (lef == rig) {
    proiz[v] = make_pair(a[lef], 1);
    bitmask[v] = make_pair(mask[a[lef]], 0);
    return;
  }
  int mid = (lef + rig) / 2;
  build(2 * v, lef, mid);
  build(2 * v + 1, mid + 1, rig);
  proiz[v] = make_pair(proiz[2 * v].first * proiz[2 * v + 1].first % MOD, 1);
  bitmask[v] = make_pair(bitmask[2 * v].first | bitmask[2 * v + 1].first, 0);
  return;
}
void full(int v, int lef, int rig, long long val, long long mask) {
  bitmask[v].first |= mask;
  bitmask[v].second |= mask;
  proiz[v].second = (proiz[v].second * val) % MOD;
  proiz[v].first = (proiz[v].first * binpow(val, rig - lef + 1)) % MOD;
  return;
}
void push(int v, int lef, int rig) {
  int mid = (lef + rig) / 2;
  full(2 * v, lef, mid, proiz[v].second, bitmask[v].second);
  full(2 * v + 1, mid + 1, rig, proiz[v].second, bitmask[v].second);
  proiz[v].second = 1, bitmask[v].second = 0;
  return;
}
void update(int v, int lef, int rig, int A, int B, long long val,
            long long mask) {
  if (lef > B || rig < A) return;
  if (A <= lef && rig <= B) {
    full(v, lef, rig, val, mask);
    return;
  }
  push(v, lef, rig);
  int mid = (lef + rig) / 2;
  update(2 * v, lef, mid, A, B, val, mask);
  update(2 * v + 1, mid + 1, rig, A, B, val, mask);
  proiz[v].first = proiz[2 * v].first * proiz[2 * v + 1].first % MOD;
  bitmask[v].first = (bitmask[2 * v].first | bitmask[2 * v + 1].first);
  return;
}
pair<long long, long long> get(int v, int lef, int rig, int A, int B) {
  if (lef > B || rig < A) return make_pair(1, 0);
  if (A <= lef && rig <= B) return make_pair(proiz[v].first, bitmask[v].first);
  push(v, lef, rig);
  int mid = (lef + rig) / 2;
  pair<long long, long long> M = get(2 * v, lef, mid, A, B);
  pair<long long, long long> N = get(2 * v + 1, mid + 1, rig, A, B);
  return make_pair(M.first * N.first % MOD, M.second | N.second);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int sch = 0;
  for (int i = 1; i <= 300; i++)
    if (prost(i)) {
      prime[sch] = i;
      number[i] = sch;
      value[sch] = (1 - revers(i) + MOD) % MOD;
      sch++;
    }
  for (int i = 1; i <= 300; i++) {
    int cop = i, uk = 2;
    while (uk * uk <= cop) {
      bool fl = false;
      while (cop % uk == 0) cop /= uk, fl = true;
      if (fl) mask[i] += (1ll << number[uk]);
      uk++;
    }
    if (cop > 1) mask[i] += (1ll << number[cop]);
  }
  build(1, 1, n);
  for (int rep = 1; rep <= q; rep++) {
    string s;
    cin >> s;
    if (s == "MULTIPLY") {
      int lef, rig, val;
      cin >> lef >> rig >> val;
      update(1, 1, n, lef, rig, val, mask[val]);
    } else {
      int lef, rig;
      cin >> lef >> rig;
      pair<long long, long long> A = get(1, 1, n, lef, rig);
      for (int i = 0; i < 62; i++)
        if (((1ll << i) & A.second) != 0) A.first = (A.first * value[i]) % MOD;
      cout << A.first << '\n';
    }
  }
  return 0;
}
