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 int64_t M = 4e5 + 5;
const int64_t N = 301;
const int64_t mod = 1e9 + 7;
int64_t n, q, p, a[M], primes[N], isPrime[N], inv[N];
struct st {
  int64_t arr, pr;
  st() {
    arr = 1;
    pr = 0;
  }
} tree[4 * M], lazy[4 * M];
int64_t power(int64_t x, int64_t y) {
  int64_t ans = 1;
  while (y) {
    if (y & 1) ans = (ans * x) % mod;
    y >>= 1;
    x = (x * x) % mod;
  }
  return ans % mod;
}
int64_t modInv(int64_t x) { return power(x, mod - 2); }
void Sieve() {
  memset(isPrime, 1, sizeof(isPrime));
  for (int64_t i = 2; i * i < N; i++) {
    if (!isPrime[i]) continue;
    for (int64_t j = i * i; j < N; j += i) isPrime[j] = 0;
  }
  for (int64_t i = 2; i < N; i++)
    if (isPrime[i]) {
      primes[p] = i;
      inv[p++] = ((i - 1) * modInv(i)) % mod;
    }
}
st merge(st a, st b) {
  st res;
  res.arr = (1LL * a.arr * b.arr) % mod;
  res.pr = a.pr | b.pr;
  return res;
}
void push(int64_t node, int64_t start, int64_t end) {
  if (lazy[node].arr != 0) {
    tree[node].arr =
        (tree[node].arr * power(lazy[node].arr, end - start + 1)) % mod;
    tree[node].pr |= lazy[node].pr;
    if (start != end) {
      lazy[node << 1].arr = (lazy[node << 1].arr * lazy[node].arr) % mod;
      lazy[node << 1].pr |= lazy[node].pr;
      lazy[node << 1 | 1].arr =
          (lazy[node << 1 | 1].arr * lazy[node].arr) % mod;
      lazy[node << 1 | 1].pr |= lazy[node].pr;
    }
    lazy[node].arr = 1;
    lazy[node].pr = 0;
  }
}
void build(int64_t node, int64_t start, int64_t end) {
  if (start == end) {
    tree[node].arr = a[start];
    for (int64_t i = 0; i < p; i++)
      if (a[start] % primes[i] == 0) tree[node].pr |= (1LL << i);
    return;
  }
  int64_t mid = (start + end) >> 1;
  build(node << 1, start, mid);
  build(node << 1 | 1, mid + 1, end);
  tree[node] = merge(tree[node << 1], tree[node << 1 | 1]);
}
void update(int64_t node, int64_t start, int64_t end, int64_t l, int64_t r,
            st val) {
  push(node, start, end);
  if (start > end || start > r || end < l) return;
  if (start >= l && end <= r) {
    lazy[node] = val;
    push(node, start, end);
    return;
  }
  int64_t mid = (start + end) >> 1;
  update(node << 1, start, mid, l, r, val);
  update(node << 1 | 1, mid + 1, end, l, r, val);
  tree[node] = merge(tree[node << 1], tree[node << 1 | 1]);
}
st query(int64_t node, int64_t start, int64_t end, int64_t l, int64_t r) {
  st res;
  if (start > end || start > r || end < l) return res;
  push(node, start, end);
  if (start >= l && end <= r) return tree[node];
  int64_t mid = (start + end) >> 1;
  st p1 = query(node << 1, start, mid, l, r);
  st p2 = query(node << 1 | 1, mid + 1, end, l, r);
  if (!p1.arr) return p2;
  if (!p2.arr) return p1;
  res = merge(p1, p2);
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Sieve();
  cin >> n >> q;
  for (int64_t i = 1; i <= n; i++) cin >> a[i];
  build(1, 1, n);
  while (q--) {
    string s;
    cin >> s;
    int64_t l, r;
    cin >> l >> r;
    if (s[0] == 'M') {
      int64_t x;
      cin >> x;
      st val;
      val.pr = 0;
      val.arr = x;
      for (int64_t i = 0; i < p; i++)
        if (x % primes[i] == 0) val.pr |= (1LL << i);
      update(1, 1, n, l, r, val);
    } else {
      st res = query(1, 1, n, l, r);
      int64_t ans = res.arr;
      for (int64_t i = 0; i < p; i++)
        if (res.pr & (1LL << i)) ans = (ans * inv[i]) % mod;
      cout << ans << endl;
    }
  }
  return 0;
}
