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 MOD = 1e9 + 7;
const int MAX = 4e5 + 5;
int a[MAX];
vector<int> primes, inv_primes;
int add(int a, int b) { return (a + b >= MOD ? a + b - MOD : a + b); }
int sub(int a, int b) { return (a >= b ? a - b : MOD + a - b); }
int mult(int a, int b) { return (1LL * a * b) % MOD; }
int fast_pow(int a, int n) {
  int r = 1;
  while (n) {
    if (n % 2) r = mult(r, a);
    n /= 2;
    a = mult(a, a);
  }
  return r;
}
struct node {
  int modify, val;
  int64_t prime_mask, push_mask;
} tree[4 * MAX];
void build(int v, int l, int r) {
  if (l == r) {
    tree[v].val = a[l];
    tree[v].modify = 1;
    for (int i = 0; i != primes.size(); i++)
      if (a[l] % primes[i] == 0) tree[v].prime_mask |= (1LL << int64_t(i));
    tree[v].push_mask = 0LL;
  } else {
    int m = l + (r - l) / 2;
    build(2 * v + 1, l, m);
    build(2 * v + 2, m + 1, r);
    tree[v].val = mult(tree[2 * v + 1].val, tree[2 * v + 2].val);
    tree[v].modify = mult(tree[2 * v + 1].modify, tree[2 * v + 2].modify);
    tree[v].prime_mask =
        tree[2 * v + 1].prime_mask | tree[2 * v + 2].prime_mask;
    tree[v].push_mask = tree[2 * v + 1].push_mask | tree[2 * v + 2].push_mask;
  }
}
void push(int v, int vl, int vr) {
  if (tree[v].modify != 1) {
    tree[v].val = mult(tree[v].val, fast_pow(tree[v].modify, vr - vl + 1));
  }
  tree[v].prime_mask |= tree[v].push_mask;
  if (vl != vr) {
    tree[2 * v + 1].modify = mult(tree[2 * v + 1].modify, tree[v].modify);
    tree[2 * v + 2].modify = mult(tree[2 * v + 2].modify, tree[v].modify);
    tree[2 * v + 1].push_mask |= tree[v].push_mask;
    tree[2 * v + 2].push_mask |= tree[v].push_mask;
  }
  tree[v].modify = 1;
  tree[v].push_mask = 0;
}
pair<int, int64_t> get(int v, int vl, int vr, int l, int r) {
  if (vr < l || r < vl) return make_pair<int, int64_t>(1, 0LL);
  push(v, vl, vr);
  if (l <= vl && vr <= r) return make_pair(tree[v].val, tree[v].prime_mask);
  int vm = vl + (vr - vl) / 2;
  auto r1 = get(2 * v + 1, vl, vm, l, r);
  auto r2 = get(2 * v + 2, vm + 1, vr, l, r);
  return make_pair(mult(r1.first, r2.first), r1.second | r2.second);
}
void multiply(int v, int vl, int vr, int l, int r, int x, int64_t mask) {
  push(v, vl, vr);
  if (vr < l || r < vl || vl > vr) return;
  if (l <= vl && vr <= r) {
    tree[v].push_mask = mask;
    tree[v].modify = x;
    push(v, vl, vr);
    return;
  }
  int vm = vl + (vr - vl) / 2;
  multiply(2 * v + 1, vl, vm, l, r, x, mask);
  multiply(2 * v + 2, vm + 1, vr, l, r, x, mask);
  tree[v].val = mult(tree[2 * v + 1].val, tree[2 * v + 2].val);
  tree[v].prime_mask = tree[2 * v + 1].prime_mask | tree[2 * v + 2].prime_mask;
  tree[v].prime_mask |= tree[2 * v + 1].push_mask | tree[2 * v + 2].push_mask;
}
int main() {
  std::iostream::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  for (int i = 2; i <= 300; i++) {
    bool ok = true;
    for (int j = 2; j * j <= i && ok; j++)
      if (i % j == 0) ok = false;
    if (ok) {
      primes.push_back(i);
      inv_primes.push_back(fast_pow(i, MOD - 2));
    }
  }
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  build(0, 0, n - 1);
  string str;
  while (q--) {
    cin >> str;
    if (str == "TOTIENT") {
      int l, r;
      cin >> l >> r;
      l--;
      r--;
      pair<int, int64_t> prod = get(0, 0, n - 1, l, r);
      for (int i = 0; i != primes.size(); ++i)
        if (prod.second & (1LL << int64_t(i)))
          prod.first = mult(mult(prod.first, primes[i] - 1), inv_primes[i]);
      cout << prod.first << endl;
    } else {
      int l, r, x;
      cin >> l >> r >> x;
      l--;
      r--;
      int64_t msk = 0LL;
      for (int i = 0; i != primes.size(); i++)
        if (x % primes[i] == 0) msk |= (1LL << int64_t(i));
      multiply(0, 0, n - 1, l, r, x, msk);
    }
  }
  return 0;
}
