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 N = 4e5 + 5;
const int mod = 1e9 + 7;
int mul(int a, int b) {
  a = (a + mod) % mod;
  b = (b + mod) % mod;
  return ((long long)a * b) % mod;
}
int add(int a, int b) {
  a = (a + mod) % mod;
  b = (b + mod) % mod;
  return (a + b) % mod;
}
int fastpow(int base, long long power) {
  if (!power) return 1;
  int ret = fastpow(base, power / 2);
  ret = mul(ret, ret);
  if (power & 1) ret = mul(ret, base);
  return ret;
}
bool isprime(int a) {
  for (int i = 2; i * i <= a; i++) {
    if (a % i == 0) return false;
  }
  return true;
}
int tree1[4 * N];
int lazy1[4 * N];
long long tree2[4 * N];
long long lazy2[4 * N];
void propagate1(int node, int l, int r) {
  if (lazy1[node] == 1) return;
  tree1[node] = mul(tree1[node], fastpow(lazy1[node], r - l + 1));
  if (l != r) {
    lazy1[node * 2] = mul(lazy1[node * 2], lazy1[node]);
    lazy1[node * 2 + 1] = mul(lazy1[node * 2 + 1], lazy1[node]);
  }
  lazy1[node] = 1;
}
void update1(int node, int l, int r, int st, int en, int val) {
  propagate1(node, l, r);
  if (st > r || en < l) return;
  if (st <= l && r <= en) {
    tree1[node] = mul(tree1[node], fastpow(val, (r - l + 1)));
    if (l != r) {
      lazy1[node * 2] = mul(lazy1[node * 2], val);
      lazy1[node * 2 + 1] = mul(lazy1[node * 2 + 1], val);
    }
    return;
  }
  int mid = (l + r) / 2;
  update1(node * 2, l, mid, st, en, val);
  update1(node * 2 + 1, mid + 1, r, st, en, val);
  tree1[node] = mul(tree1[node * 2], tree1[node * 2 + 1]);
}
int query1(int node, int l, int r, int st, int en) {
  if (st > r || en < l) return 1;
  propagate1(node, l, r);
  if (st <= l && r <= en) return tree1[node];
  int mid = (l + r) / 2;
  return mul(query1(node * 2, l, mid, st, en),
             query1(node * 2 + 1, mid + 1, r, st, en));
}
void propagate2(int node, int l, int r) {
  tree2[node] |= lazy2[node];
  if (l != r) {
    lazy2[node * 2] |= lazy2[node];
    lazy2[node * 2 + 1] |= lazy2[node];
  }
  lazy2[node] = 0;
}
void update2(int node, int l, int r, int st, int en, long long val) {
  if (st > r || en < l) return;
  propagate2(node, l, r);
  if (st <= l && r <= en) {
    tree2[node] |= val;
    if (l != r) {
      lazy2[node * 2] |= val;
      lazy2[node * 2 + 1] |= val;
    }
    return;
  }
  int mid = (l + r) / 2;
  update2(node * 2, l, mid, st, en, val);
  update2(node * 2 + 1, mid + 1, r, st, en, val);
  tree2[node] = (tree2[node * 2] | tree2[node * 2 + 1]);
}
long long query2(int node, int l, int r, int st, int en) {
  if (st > r || en < l) return 0;
  propagate2(node, l, r);
  if (st <= l && r <= en) return tree2[node];
  int mid = (l + r) / 2;
  return query2(node * 2, l, mid, st, en) |
         query2(node * 2 + 1, mid + 1, r, st, en);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  for (int i = 0; i < 4 * N; i++) tree1[i] = lazy1[i] = 1;
  vector<int> primes, inv;
  for (int i = 2; i <= 300; i++) {
    if (isprime(i)) {
      primes.push_back(i);
      inv.push_back(fastpow(i, mod - 2));
    }
  }
  int m = primes.size();
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    update1(1, 1, n, i, i, a);
    long long mask = 0;
    for (int j = 0; j < m; j++) {
      if (a % primes[j] == 0) {
        mask |= ((long long)1 << j);
        while (a % primes[j] == 0) {
          a /= primes[j];
        }
      }
    }
    update2(1, 1, n, i, i, mask);
  }
  while (q--) {
    string type;
    cin >> type;
    if (type == "MULTIPLY") {
      int l, r, a;
      cin >> l >> r >> a;
      update1(1, 1, n, l, r, a);
      long long mask = 0;
      for (int j = 0; j < m; j++) {
        if (a % primes[j] == 0) {
          mask |= ((long long)1 << j);
          while (a % primes[j] == 0) {
            a /= primes[j];
          }
        }
      }
      update2(1, 1, n, l, r, mask);
    } else {
      int l, r;
      cin >> l >> r;
      int ans = query1(1, 1, n, l, r);
      long long mask = query2(1, 1, n, l, r);
      for (int j = 0; j < m; j++) {
        if (mask & ((long long)1 << j)) {
          ans = mul(ans, 1 - inv[j]);
        }
      }
      cout << ans << '\n';
    }
  }
  return 0;
}
