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;
long long inv[303];
pair<long long, long long> tree[4 * 400050];
pair<long long, long long> lazy[4 * 400050];
long long arr[400050];
long long prmBit[303];
long long mul(long long a, long long b) {
  if (a > 1000000007) a %= 1000000007;
  if (b > 1000000007) b %= 1000000007;
  if (a < 0) a += 1000000007;
  if (b < 0) b += 1000000007;
  long long r = a * b;
  if (r > 1000000007) return r % 1000000007;
  if (r < 0) return (r + 1000000007) % 1000000007;
  return r;
}
long long bm(long long a, long long b) {
  long long r = 1LL;
  a %= 1000000007;
  while (b) {
    if (b & 1LL) r = mul(r, a) % 1000000007;
    a = mul(a, a) % 1000000007;
    b >>= 1LL;
  }
  return r;
}
pair<long long, long long> Merge(pair<long long, long long> a,
                                 pair<long long, long long> b) {
  pair<long long, long long> res;
  res.first = mul(a.first, b.first);
  res.second = a.second | b.second;
  return res;
}
void lzu(int st, int en, int n) {
  if (lazy[n].second == 0) return;
  tree[n].first = mul(tree[n].first, bm(lazy[n].first, en - st + 1));
  tree[n].second = (tree[n].second | lazy[n].second);
  if (st != en) {
    lazy[n + n].first = mul(lazy[n + n].first, lazy[n].first);
    lazy[n + n].first %= 1000000007;
    lazy[n + n + 1].first = mul(lazy[n + n + 1].first, lazy[n].first);
    lazy[n + n + 1].first %= 1000000007;
    lazy[n + n].second |= lazy[n].second;
    lazy[n + n + 1].second |= lazy[n].second;
  }
  lazy[n] = {1, 0};
}
void build(int st, int en, int n) {
  lazy[n] = make_pair(1, 0);
  if (st == en) {
    tree[n] = make_pair(arr[st], prmBit[arr[st]]);
    return;
  }
  build(st, (st + en) / 2, n + n);
  build((st + en) / 2 + 1, en, n + n + 1);
  tree[n] = Merge(tree[n + n], tree[n + n + 1]);
}
void update(int st, int en, int n, int l, int r, long long val) {
  lzu(st, en, n);
  if (en < l || r < st) return;
  if (l <= st && en <= r) {
    lazy[n] =
        make_pair((mul(lazy[n].first, val)), (lazy[n].second | prmBit[val]));
    lzu(st, en, n);
    return;
  }
  update(st, (st + en) / 2, n + n, l, r, val);
  update((st + en) / 2 + 1, en, n + n + 1, l, r, val);
  tree[n] = Merge(tree[n + n], tree[n + n + 1]);
}
pair<long long, long long> query(int st, int en, int n, int l, int r) {
  lzu(st, en, n);
  if (en < l || r < st) return {1, 0};
  if (l <= st && en <= r) return tree[n];
  return Merge(query(st, (st + en) / 2, n + n, l, r),
               query((st + en) / 2 + 1, en, n + n + 1, l, r));
}
vector<int> prm;
void prmCalc() {
  bool isPrm[400];
  memset(isPrm, 0, sizeof isPrm);
  for (int i = 2; i <= 300; i++) {
    if (!isPrm[i]) {
      prm.push_back(i);
      for (int j = i + i; j <= 300; j += i) {
        isPrm[j] = 1;
      }
    }
  }
}
void binary(int n, int d = 0) {
  if (!n && !d) printf("0");
  if (!n) return;
  binary(n / 2, d + 1);
  printf("%d", n % 2);
}
int main() {
  long long n, q, l, r, val;
  prmCalc();
  inv[1] = 1;
  for (int i = 2; i <= 300; i++) inv[i] = bm(i, 1000000007 - 2);
  for (int i = 1; i <= 300; i++) {
    for (int j = 0; j < 62; j++)
      if (i % prm[j] == 0) prmBit[i] |= 1LL << j;
  }
  scanf("%lld%lld", &n, &q);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
  }
  build(0, n - 1, 1);
  char str[20];
  while (q--) {
    scanf("%s", str);
    if (str[0] == 'M') {
      scanf("%lld%lld%lld", &l, &r, &val);
      update(0, n - 1, 1, l - 1, r - 1, val);
    } else {
      scanf("%lld%lld", &l, &r);
      pair<long long, long long> totientVal = query(0, n - 1, 1, l - 1, r - 1);
      long long totRes =
          (totientVal.first + 1000000007 + 1000000007) % 1000000007;
      for (int i = 0; i < 62; i++) {
        if (totientVal.second & (1LL << i)) {
          totRes = mul(totRes, inv[prm[i]]);
          totRes = mul(totRes, prm[i] - 1);
        }
      }
      printf("%lld\n", totRes);
    }
  }
  return 0;
}
