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;
pair<long long, long long> tree[4 * 400005];
pair<long long, long long> prop[4 * 400005];
long long arr[400005];
long long mask[310];
long long po[65];
pair<long long, long long> nll = make_pair(1, 0);
vector<long long> prime;
char str[10];
void gen() {
  po[0] = 1;
  for (long long i = 1; i < 65; i++) po[i] = po[i - 1] * 2;
  for (long long i = 2; i <= 300; i++) {
    bool p = true;
    for (long long j = 2; j < i; j++) {
      if (i % j == 0) p = false;
    }
    if (p) prime.push_back(i);
  }
  for (long long i = 1; i <= 300; i++) {
    mask[i] = 0;
    for (long long j = 0; j < prime.size(); j++) {
      if (i % prime[j] == 0) mask[i] = mask[i] + po[j];
    }
  }
}
long long bigMod(long long a, long long p) {
  if (p == 0) return 1LL;
  if (p == 1) return a;
  long long ret = bigMod(a, p / 2);
  ret = (ret * ret) % 1000000007;
  if (p & 1) ret = (ret * a) % 1000000007;
  return ret;
}
void init(int node, int b, int e) {
  if (b == e) {
    tree[node].first = arr[b];
    tree[node].second = mask[arr[b]];
    return;
  }
  long long left = 2 * node;
  long long right = 2 * node + 1;
  long long mid = (b + e) / 2;
  init(left, b, mid);
  init(right, mid + 1, e);
  tree[node].first = (tree[left].first * tree[right].first) % 1000000007;
  tree[node].second = tree[left].second | tree[right].second;
}
void propagate(int node, int b, int e) {
  if (prop[node].first == 1) return;
  long long k = e - b + 1;
  tree[node].first =
      (tree[node].first * bigMod(prop[node].first, k)) % 1000000007;
  tree[node].second = tree[node].second | prop[node].second;
  if (b != e) {
    long long left = 2 * node;
    long long right = 2 * node + 1;
    prop[left].first = (prop[left].first * prop[node].first) % 1000000007;
    prop[left].second = prop[left].second | prop[node].second;
    prop[right].first = (prop[right].first * prop[node].first) % 1000000007;
    prop[right].second = prop[right].second | prop[node].second;
  }
  prop[node].first = 1;
  prop[node].second = 0;
}
void update(int node, int b, int e, int l, int r, long long val) {
  propagate(node, b, e);
  if (l > e || r < b) return;
  if (b >= l && e <= r) {
    long long cnt = e - b + 1;
    prop[node].first = (prop[node].first * val) % 1000000007;
    prop[node].second = prop[node].second | mask[val];
    propagate(node, b, e);
    return;
  }
  int left = 2 * node;
  int right = 2 * node + 1;
  int mid = (b + e) / 2;
  update(left, b, mid, l, r, val);
  update(right, mid + 1, e, l, r, val);
  tree[node].first = (tree[left].first * tree[right].first) % 1000000007;
  tree[node].second = tree[left].second | tree[right].second;
}
pair<long long, long long> query(int node, int b, int e, int l, int r) {
  propagate(node, b, e);
  if (l > e || r < b) return nll;
  if (b >= l && e <= r) {
    return tree[node];
  }
  int left = 2 * node;
  int right = 2 * node + 1;
  int mid = (b + e) / 2;
  pair<long long, long long> q1 = query(left, b, mid, l, r);
  pair<long long, long long> q2 = query(right, mid + 1, e, l, r);
  pair<long long, long long> q;
  q.first = (q1.first * q2.first) % 1000000007;
  q.second = q1.second | q2.second;
  return q;
}
long long calc(long long m) {
  long long lob = 1, hor = 1;
  for (long long i = 0; i < 62; i++) {
    if (m & po[i]) {
      long long p = prime[i];
      lob = (lob * (p - 1)) % 1000000007;
      hor = (hor * p) % 1000000007;
    }
  }
  hor = bigMod(hor, 1000000007 - 2);
  long long ans = (lob * hor) % 1000000007;
  return ans;
}
int main() {
  gen();
  long long n, q;
  scanf("%lld %lld", &n, &q);
  for (int i = 0; i < 4 * 400005; i++) {
    prop[i].first = 1, prop[i].second = 0;
  }
  for (long long i = 1; i <= n; i++) scanf("%d", &arr[i]);
  init(1, 1, n);
  for (long long i = 0; i < q; i++) {
    scanf("%s", str);
    if (str[0] == 'M') {
      long long l, r, x;
      scanf("%lld %lld %lld", &l, &r, &x);
      update(1, 1, n, l, r, x);
    } else {
      long long l, r;
      scanf("%lld %lld", &l, &r);
      pair<long long, long long> p = query(1, 1, n, l, r);
      long long ans = (p.first * calc(p.second)) % 1000000007;
      printf("%lld\n", ans);
    }
  }
}
