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>
#pragma GCC optimize("O3")
using namespace std;
const int N = 400031;
long long pw(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2) return a * pw(a, b - 1) % 1000000007;
  return pw(a * a % 1000000007, b / 2);
}
long long inver[331];
int pr[331];
vector<int> primes;
int n;
int tests;
int ar[N];
long long M[N];
pair<long long, long long> t[N * 4];
pair<long long, long long> tomult[N * 4];
long long get_pw(long long val, int p) { return pw(val, p); }
void push(int v, int tl, int tr) {
  int sdfjahlfasfh = tl + tr;
  sdfjahlfasfh /= 2;
  if (tomult[v].first != 1) {
    tomult[v * 2].first = (tomult[v * 2].first * tomult[v].first) % 1000000007;
    tomult[v * 2 + 1].first =
        (tomult[v * 2 + 1].first * tomult[v].first) % 1000000007;
    long long le = get_pw(tomult[v].first, sdfjahlfasfh - tl + 1);
    long long ri = get_pw(tomult[v].first, tr - sdfjahlfasfh);
    t[v * 2].first = (t[v * 2].first * le) % 1000000007;
    t[v * 2 + 1].first = (t[v * 2 + 1].first * ri) % 1000000007;
    tomult[v].first = 1;
  }
  if (tomult[v].second != 0) {
    tomult[v * 2].second |= tomult[v].second;
    tomult[v * 2 + 1].second |= tomult[v].second;
    t[v * 2].second |= tomult[v].second;
    t[v * 2 + 1].second |= tomult[v].second;
    tomult[v].second = 0;
  }
}
void build(int v, int tl, int tr) {
  tomult[v].first = 1;
  if (tl == tr) {
    t[v].first = ar[tl];
    t[v].second = M[tl];
    return;
  }
  int sdfjahlfasfh = tl + tr;
  sdfjahlfasfh /= 2;
  build(v * 2, tl, sdfjahlfasfh);
  build(v * 2 + 1, sdfjahlfasfh + 1, tr);
  t[v].first = (t[v * 2].first * t[v * 2 + 1].first) % 1000000007;
  t[v].second = (t[v * 2].second | t[v * 2 + 1].second);
}
void update(int v, int tl, int tr, int l, int r, int val, long long msk) {
  if (l > r) return;
  if (tl == l && tr == r) {
    t[v].first = t[v].first * get_pw(val, tr - tl + 1) % 1000000007;
    t[v].second |= msk;
    tomult[v].first *= val;
    tomult[v].first %= 1000000007;
    tomult[v].second |= msk;
    return;
  }
  push(v, tl, tr);
  int sdfjahlfasfh = tl + tr;
  sdfjahlfasfh /= 2;
  update(v * 2, tl, sdfjahlfasfh, l, min(r, sdfjahlfasfh), val, msk);
  update(v * 2 + 1, sdfjahlfasfh + 1, tr, max(sdfjahlfasfh + 1, l), r, val,
         msk);
  t[v].first = t[v * 2].first * t[v * 2 + 1].first % 1000000007;
  t[v].second = (t[v * 2].second | t[v * 2 + 1].second);
}
pair<long long, long long> get(int v, int tl, int tr, int l, int r) {
  if (l > r) return make_pair(1, 0);
  if (l == tl && r == tr) return t[v];
  push(v, tl, tr);
  int sdfjahlfasfh = tl + tr;
  sdfjahlfasfh /= 2;
  pair<long long, long long> p1 =
      get(v * 2, tl, sdfjahlfasfh, l, min(r, sdfjahlfasfh));
  pair<long long, long long> p2 =
      get(v * 2 + 1, sdfjahlfasfh + 1, tr, max(sdfjahlfasfh + 1, l), r);
  p1.first = (p1.first * p2.first) % 1000000007;
  p1.second |= p2.second;
  return p1;
}
int main() {
  pr[1] = 1;
  for (int i = 2; i <= 300; i++) {
    if (pr[i] == 0) {
      for (int j = i * 2; j <= 300; j += i) {
        pr[j] = 1;
      }
    }
  }
  for (int i = 1; i <= 300; i++) {
    inver[i] = pw(i, 1000000007 - 2);
  }
  for (int i = 2; i <= 300; i++) {
    if (pr[i] == 0) primes.push_back(i);
  }
  cin >> n >> tests;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ar[i]);
  }
  for (int i = 1; i <= n; i++) {
    long long msk = 0;
    for (int j = 0; j < primes.size(); j++) {
      if (ar[i] % primes[j] == 0) {
        msk |= (1ll << j);
      }
    }
    M[i] = msk;
  }
  build(1, 1, n);
  for (; tests; --tests) {
    string s;
    cin >> s;
    if (s == "TOTIENT") {
      int l, r;
      scanf("%d", &l);
      scanf("%d", &r);
      pair<long long, long long> res = get(1, 1, n, l, r);
      for (int i = 0; i < primes.size(); i++) {
        if (res.second & (1ll << i)) {
          res.first = res.first * inver[primes[i]];
          res.first %= 1000000007;
          res.first *= primes[i] - 1;
          res.first %= 1000000007;
        }
      }
      printf("%lld\n", res.first);
    } else {
      int l, r, val;
      scanf("%d", &l);
      scanf("%d", &r);
      scanf("%d", &val);
      long long msk = 0;
      for (int j = 0; j < primes.size(); j++) {
        if (val % primes[j] == 0) {
          msk |= (1ll << j);
        }
      }
      update(1, 1, n, l, r, val, msk);
    }
  }
  return 0;
}
