#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
pair<long long, long long> st[1600005];
pair<long long, long long> lazy[1600005];
long long bm[305], inv[64];
int datas[400005];
vector<int> prime;
pair<long long, long long> merge(pair<long long, long long> X,
                                 pair<long long, long long> Y) {
  X.first *= Y.first;
  X.first %= MOD;
  X.second |= Y.second;
  return X;
}
long long fexpo(int p, long long base) {
  if (p == 0) return 1;
  if (p == 1) return base % MOD;
  if (p % 2 == 1) return (fexpo(p - 1, base) * (base % MOD)) % MOD;
  long long h = fexpo(p / 2, base);
  return (h * h) % MOD;
}
void build(int pos, int L, int R) {
  if (L == R) {
    st[pos].first = datas[L];
    st[pos].second = bm[datas[L]];
    return;
  }
  int mid = (L + R) / 2;
  build(pos * 2, L, mid);
  build(pos * 2 + 1, mid + 1, R);
  st[pos] = merge(st[pos * 2], st[pos * 2 + 1]);
}
void relax(int &pos, int &L, int &R) {
  st[pos].first *= fexpo((R - L + 1), lazy[pos].first % MOD);
  st[pos].first %= MOD;
  st[pos].second |= lazy[pos].second;
  if (L != R) {
    lazy[pos * 2].first *= lazy[pos].first;
    lazy[pos * 2].first %= MOD;
    lazy[pos * 2].second |= lazy[pos].second;
    lazy[pos * 2 + 1].first *= lazy[pos].first;
    lazy[pos * 2 + 1].first %= MOD;
    lazy[pos * 2 + 1].second |= lazy[pos].second;
  }
  lazy[pos] = pair<long long, long long>(1, 0);
}
pair<long long, long long> query(int pos, int L, int R, int S, int E) {
  if (lazy[pos].second > 0) {
    relax(pos, L, R);
  }
  if (L > E || R < S) return pair<long long, long long>(1, 0);
  if (L >= S && R <= E) return st[pos];
  int mid = (L + R) / 2;
  return merge(query(pos * 2, L, mid, S, E),
               query(pos * 2 + 1, mid + 1, R, S, E));
}
void upd(int pos, int L, int R, int S, int E, pair<long long, long long> val) {
  if (lazy[pos].second > 0) {
    relax(pos, L, R);
  }
  if (L > E || R < S) return;
  if (L >= S && R <= E) {
    lazy[pos] = val;
    relax(pos, L, R);
    return;
  }
  int mid = (L + R) / 2;
  upd(pos * 2, L, mid, S, E, val);
  upd(pos * 2 + 1, mid + 1, R, S, E, val);
  st[pos] = merge(st[pos * 2], st[pos * 2 + 1]);
}
string pbm(long long inp) {
  string ret = "";
  while (inp > 0) {
    if (inp % 2 == 1)
      ret.push_back('1');
    else
      ret.push_back('0');
    inp /= 2;
  }
  for (int a = 0; a < ret.size() / 2; a++) {
    swap(ret[a], ret[ret.size() - 1 - a]);
  }
  return ret;
}
long long hasil(pair<long long, long long> inp) {
  long long ret = 1;
  int ix = 0;
  while (inp.second > 0) {
    if (inp.second % 2 == 1) {
      ret *= inv[ix];
      ret %= MOD;
    }
    ix++;
    inp.second /= 2;
  }
  ret *= inp.first;
  ret %= MOD;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int a = 0; a <= 1600000; a++) {
    lazy[a].first = 1;
  }
  for (int a = 2; a <= 300; a++) {
    bool check = 0;
    for (int b = 2; b < a; b++) {
      if (a % b == 0) check = 1;
    }
    if (!check) prime.push_back(a);
  }
  for (int a = 2; a <= 300; a++) {
    for (int b = 0; b < prime.size(); b++) {
      if (a % prime[b] == 0) {
        bm[a] |= (1LL << b);
      }
    }
  }
  for (int a = 0; a < prime.size(); a++) {
    inv[a] = fexpo(MOD - 2, prime[a]);
    inv[a] = ((1 - inv[a]) % MOD + MOD) % MOD;
  }
  int n, q;
  cin >> n >> q;
  for (int a = 1; a <= n; a++) {
    cin >> datas[a];
  }
  build(1, 1, n);
  string S;
  int L, R, val;
  for (int a = 0; a < q; a++) {
    cin >> S >> L >> R;
    if (S == "TOTIENT") {
      cout << hasil(query(1, 1, n, L, R)) << endl;
    } else {
      cin >> val;
      upd(1, 1, n, L, R, pair<long long, long long>(val, bm[val]));
    }
  }
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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 MOD = 1e9 + 7;
pair<long long, long long> st[1600005];
pair<long long, long long> lazy[1600005];
long long bm[305], inv[64];
int datas[400005];
vector<int> prime;
pair<long long, long long> merge(pair<long long, long long> X,
                                 pair<long long, long long> Y) {
  X.first *= Y.first;
  X.first %= MOD;
  X.second |= Y.second;
  return X;
}
long long fexpo(int p, long long base) {
  if (p == 0) return 1;
  if (p == 1) return base % MOD;
  if (p % 2 == 1) return (fexpo(p - 1, base) * (base % MOD)) % MOD;
  long long h = fexpo(p / 2, base);
  return (h * h) % MOD;
}
void build(int pos, int L, int R) {
  if (L == R) {
    st[pos].first = datas[L];
    st[pos].second = bm[datas[L]];
    return;
  }
  int mid = (L + R) / 2;
  build(pos * 2, L, mid);
  build(pos * 2 + 1, mid + 1, R);
  st[pos] = merge(st[pos * 2], st[pos * 2 + 1]);
}
void relax(int &pos, int &L, int &R) {
  st[pos].first *= fexpo((R - L + 1), lazy[pos].first % MOD);
  st[pos].first %= MOD;
  st[pos].second |= lazy[pos].second;
  if (L != R) {
    lazy[pos * 2].first *= lazy[pos].first;
    lazy[pos * 2].first %= MOD;
    lazy[pos * 2].second |= lazy[pos].second;
    lazy[pos * 2 + 1].first *= lazy[pos].first;
    lazy[pos * 2 + 1].first %= MOD;
    lazy[pos * 2 + 1].second |= lazy[pos].second;
  }
  lazy[pos] = pair<long long, long long>(1, 0);
}
pair<long long, long long> query(int pos, int L, int R, int S, int E) {
  if (lazy[pos].second > 0) {
    relax(pos, L, R);
  }
  if (L > E || R < S) return pair<long long, long long>(1, 0);
  if (L >= S && R <= E) return st[pos];
  int mid = (L + R) / 2;
  return merge(query(pos * 2, L, mid, S, E),
               query(pos * 2 + 1, mid + 1, R, S, E));
}
void upd(int pos, int L, int R, int S, int E, pair<long long, long long> val) {
  if (lazy[pos].second > 0) {
    relax(pos, L, R);
  }
  if (L > E || R < S) return;
  if (L >= S && R <= E) {
    lazy[pos] = val;
    relax(pos, L, R);
    return;
  }
  int mid = (L + R) / 2;
  upd(pos * 2, L, mid, S, E, val);
  upd(pos * 2 + 1, mid + 1, R, S, E, val);
  st[pos] = merge(st[pos * 2], st[pos * 2 + 1]);
}
string pbm(long long inp) {
  string ret = "";
  while (inp > 0) {
    if (inp % 2 == 1)
      ret.push_back('1');
    else
      ret.push_back('0');
    inp /= 2;
  }
  for (int a = 0; a < ret.size() / 2; a++) {
    swap(ret[a], ret[ret.size() - 1 - a]);
  }
  return ret;
}
long long hasil(pair<long long, long long> inp) {
  long long ret = 1;
  int ix = 0;
  while (inp.second > 0) {
    if (inp.second % 2 == 1) {
      ret *= inv[ix];
      ret %= MOD;
    }
    ix++;
    inp.second /= 2;
  }
  ret *= inp.first;
  ret %= MOD;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int a = 0; a <= 1600000; a++) {
    lazy[a].first = 1;
  }
  for (int a = 2; a <= 300; a++) {
    bool check = 0;
    for (int b = 2; b < a; b++) {
      if (a % b == 0) check = 1;
    }
    if (!check) prime.push_back(a);
  }
  for (int a = 2; a <= 300; a++) {
    for (int b = 0; b < prime.size(); b++) {
      if (a % prime[b] == 0) {
        bm[a] |= (1LL << b);
      }
    }
  }
  for (int a = 0; a < prime.size(); a++) {
    inv[a] = fexpo(MOD - 2, prime[a]);
    inv[a] = ((1 - inv[a]) % MOD + MOD) % MOD;
  }
  int n, q;
  cin >> n >> q;
  for (int a = 1; a <= n; a++) {
    cin >> datas[a];
  }
  build(1, 1, n);
  string S;
  int L, R, val;
  for (int a = 0; a < q; a++) {
    cin >> S >> L >> R;
    if (S == "TOTIENT") {
      cout << hasil(query(1, 1, n, L, R)) << endl;
    } else {
      cin >> val;
      upd(1, 1, n, L, R, pair<long long, long long>(val, bm[val]));
    }
  }
  return 0;
}

```