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 MOD = 1e9 + 7;
pair<vector<int>, vector<int>> linear_sieve(const int UPBD) {
  vector<int> primes, last_prime(UPBD);
  for (int p = 2; p < UPBD; ++p) {
    if (not last_prime[p]) primes.push_back(p), last_prime[p] = p;
    for (int j = 0; primes[j] * p < UPBD; ++j) {
      last_prime[primes[j] * p] = primes[j];
      if (p % primes[j] == 0) break;
    }
  }
  return {primes, last_prime};
}
int LLmul(int a, int b) { return 1ll * a * b % MOD; }
template <typename F>
vector<F> linear_inv(F p, int k) {
  vector<F> inv(min(p, F(1 + k)));
  inv[1] = 1;
  for (int i = 2; i < inv.size(); ++i) inv[i] = LLmul((p - p / i), inv[p % i]);
  return inv;
}
auto inv = linear_inv(MOD, 303);
vector<long long> divPs;
vector<int> lp, pToID, primes;
int toFactor(long long a) {
  int ans = 1;
  for (int i = 0; i < 62; ++i) {
    if ((a >> i) & 1ll) ans = LLmul(LLmul(ans, primes[i] - 1), inv[primes[i]]);
  }
  return ans;
}
int powM(int a, int p) {
  int ret = 1;
  for (int cur = a; p; p >>= 1, cur = LLmul(cur, cur)) {
    if (p & 1) ret = LLmul(ret, cur);
  }
  return ret;
}
class Seg {
  long long bst = 0;
  long long bstTag = 0;
  int mul = 1;
  int mulTag = 1;
  int l, m, r;
  Seg* ch[2] = {};
  void pull() {
    mul = LLmul(ch[0]->mul, ch[1]->mul);
    bst = ch[0]->bst | ch[1]->bst;
  }
  void push() {
    if (bstTag) {
      for (int i = 0; i < 2; ++i) {
        ch[i]->bstTag |= bstTag;
        ch[i]->bst |= bstTag;
      }
      bstTag = 0;
    }
    if (mulTag != 1) {
      for (int i = 0; i < 2; ++i) {
        ch[i]->mulTag = LLmul(ch[i]->mulTag, mulTag);
        ch[i]->mul = LLmul(ch[i]->mul, powM(mulTag, ch[i]->size()));
      }
      mulTag = 1;
    }
  }

 public:
  int size() { return r - l; }
  Seg(int l, int r, const vector<int>& A) : l(l), r(r), m(l + r >> 1) {
    bst = 0;
    bstTag = 0;
    mul = 1;
    mulTag = 1;
    if (r - l == 1)
      mul = A[l], bst = divPs[A[l]];
    else {
      push();
      ch[0] = new Seg(l, m, A);
      ch[1] = new Seg(m, r, A);
      pull();
    }
  }
  void multiply(int ql, int qr, int v) {
    if (ql <= l and r <= qr)
      mul = LLmul(mul, powM(v, size())), mulTag = LLmul(mulTag, v);
    else {
      push();
      if (ql < m) ch[0]->multiply(ql, qr, v);
      if (m < qr) ch[1]->multiply(ql, qr, v);
      pull();
    }
  }
  void addSet(int ql, int qr, long long S) {
    if (ql <= l and r <= qr)
      bst |= S, bstTag |= S;
    else {
      push();
      if (ql < m) ch[0]->addSet(ql, qr, S);
      if (m < qr) ch[1]->addSet(ql, qr, S);
      pull();
    }
  }
  int multiplication(int ql, int qr) {
    if (ql <= l and r <= qr)
      return mul;
    else {
      int ret = 1;
      push();
      if (ql < m) ret = LLmul(ret, ch[0]->multiplication(ql, qr));
      if (m < qr) ret = LLmul(ret, ch[1]->multiplication(ql, qr));
      pull();
      return ret;
    }
  }
  long long factor(int ql, int qr) {
    if (ql <= l and r <= qr)
      return bst;
    else {
      long long ret = 0;
      push();
      if (ql < m) ret |= ch[0]->factor(ql, qr);
      if (m < qr) ret |= ch[1]->factor(ql, qr);
      pull();
      return ret;
    }
  }
};
class Solution {
  int n, q;

 public:
  void run() {
    cin >> n >> q;
    tie(primes, lp) = linear_sieve(301);
    pToID.resize(301);
    divPs.assign(301, 0);
    for (int i = 0; i < primes.size(); ++i) pToID[primes[i]] = i;
    for (int p = 2; p < 301; ++p)
      if (lp[p] == p) {
        for (int j = p; j < 301; j += p) divPs[j] |= 1ll << pToID[p];
      }
    vector<int> A(n);
    for (int i = 0; i < n; ++i) cin >> A[i];
    Seg root(0, n, A);
    while (q--) {
      string s;
      int l, r;
      cin >> s >> l >> r;
      --l;
      if (s == "TOTIENT") {
        cout << LLmul(root.multiplication(l, r), toFactor(root.factor(l, r)))
             << '\n';
      } else {
        int x;
        cin >> x;
        if (x == 1) continue;
        root.multiply(l, r, x);
        root.addSet(l, r, divPs[x]);
      }
    }
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Solution().run();
}
