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 int NMAX = 4e5;
const int QMAX = 2e5;
const int VMAX = 300;
const int MOD = 1e9 + 7;
pair<int, long long> aint[4 * NMAX + 5];
pair<int, long long> lazy[4 * NMAX + 5];
pair<int, long long> v[4 * NMAX + 5];
long long mask[VMAX + 5];
bool ciur[VMAX + 5];
char c[NMAX + 5];
void build(int nod, int st, int dr) {
  lazy[nod] = {1, 0};
  aint[nod] = {1, 0};
  if (st == dr) {
    aint[nod] = v[st];
    return;
  }
  int mid = (st + dr) / 2;
  build(nod * 2, st, mid);
  build(nod * 2 + 1, mid + 1, dr);
  aint[nod].first = 1LL * aint[nod * 2].first * aint[2 * nod + 1].first % MOD;
  aint[nod].second = aint[nod * 2].second | aint[2 * nod + 1].second;
}
int lgpow(int b, int e) {
  int p = 1;
  while (e) {
    if (e & 1) {
      p = 1LL * p * b % MOD;
    }
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return p;
}
void propag(int nod, int st, int dr) {
  if (st == dr || lazy[nod] == make_pair(1, 0LL)) {
    return;
  }
  int mid = (st + dr) / 2;
  lazy[2 * nod] = make_pair(1LL * lazy[nod].first * lazy[2 * nod].first % MOD,
                            lazy[nod].second | lazy[2 * nod].second);
  lazy[2 * nod + 1] =
      make_pair(1LL * lazy[nod].first * lazy[2 * nod + 1].first % MOD,
                lazy[nod].second | lazy[2 * nod + 1].second);
  aint[2 * nod] = make_pair(
      1LL * lgpow(lazy[nod].first, mid - st + 1) * aint[2 * nod].first % MOD,
      lazy[nod].second | aint[2 * nod].second);
  aint[2 * nod + 1] = make_pair(
      1LL * lgpow(lazy[nod].first, dr - mid) * aint[2 * nod + 1].first % MOD,
      lazy[nod].second | aint[2 * nod + 1].second);
  lazy[nod] = {1, 0};
}
void update(int nod, int st, int dr, int S, int D, pair<int, long long> val) {
  propag(nod, st, dr);
  if (D < st || S > dr) {
    return;
  }
  if (S <= st && dr <= D) {
    aint[nod].first =
        1LL * aint[nod].first * lgpow(val.first, dr - st + 1) % MOD;
    aint[nod].second = aint[nod].second | val.second;
    lazy[nod].first = 1LL * lazy[nod].first * val.first % MOD;
    lazy[nod].second = lazy[nod].second | val.second;
    return;
  }
  int mid = (st + dr) / 2;
  update(nod * 2, st, mid, S, D, val);
  update(nod * 2 + 1, mid + 1, dr, S, D, val);
  aint[nod].first = 1LL * aint[nod * 2].first * aint[2 * nod + 1].first % MOD;
  aint[nod].second = aint[nod * 2].second | aint[2 * nod + 1].second;
}
pair<int, long long> query(int nod, int st, int dr, int S, int D) {
  propag(nod, st, dr);
  if (D < st || S > dr) {
    return {1, 0};
  }
  if (S <= st && dr <= D) {
    return aint[nod];
  }
  int mid = (st + dr) / 2;
  pair<int, long long> a = query(nod * 2, st, mid, S, D);
  pair<int, long long> b = query(nod * 2 + 1, mid + 1, dr, S, D);
  a.first = 1LL * a.first * b.first % MOD;
  a.second = a.second | b.second;
  return a;
}
vector<int> primes;
vector<int> ch;
int n, q;
int main() {
  ciur[0] = ciur[1] = true;
  int sz = 0;
  for (int i = 2; i <= VMAX; i++) {
    if (ciur[i] == false) {
      for (int j = i; j <= VMAX; j += i) {
        mask[j] |= (1LL << sz);
        ciur[j] = true;
      }
      sz++;
      primes.push_back(i);
    }
  }
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v[i].first);
    v[i].second = mask[v[i].first];
  }
  build(1, 1, n);
  scanf("\n");
  while (q--) {
    scanf("%s", c);
    if (c[0] == 'T') {
      int l, r;
      scanf("%d %d\n", &l, &r);
      pair<int, long long> tmp = query(1, 1, n, l, r);
      for (int i = 0; i < (int)primes.size(); i++) {
        if ((tmp.second >> i) & 1) {
          tmp.first = 1LL * tmp.first * (primes[i] - 1) % MOD;
          tmp.first = 1LL * tmp.first * lgpow(primes[i], MOD - 2) % MOD;
        }
      }
      printf("%d\n", tmp.first);
    } else {
      int l, r, x;
      scanf("%d %d %d\n", &l, &r, &x);
      update(1, 1, n, l, r, {x, mask[x]});
    }
  }
  return 0;
}
