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;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
  if (b == 0LL) return 1LL;
  if (b == 1LL) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1LL) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
bool is_prime(int p) {
  for (int i = 2; i * i <= p; i++) {
    if (p % i == 0) return 0;
  }
  return 1;
}
const int M = 1e9 + 7;
struct node {
  long long x, mask;
  node() {}
  node(long long x, long long mask) : x(x), mask(mask) {}
  node operator+(const node& o) const {
    node r;
    r.x = (x * o.x) % M;
    r.mask = mask | o.mask;
    return r;
  }
};
const int P = 310;
long long Mask[P];
long long modpow(long long b, long long e, long long mod) {
  long long ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}
int id[P];
const int N = 4e5 + 10;
node tree[4 * N];
node lazy[4 * N];
int a[N];
void build(int no, int i, int j) {
  lazy[no] = node(1, 0);
  if (i == j) {
    tree[no].x = a[i];
    tree[no].mask = Mask[a[i]];
    return;
  }
  int mid = (i + j) >> 1, l = no << 1, r = no << 1 | 1;
  build(l, i, mid);
  build(r, mid + 1, j);
  tree[no] = tree[l] + tree[r];
}
void flush(int no, int i, int j) {
  if (lazy[no].x != 1 or lazy[no].mask != 0) {
    tree[no].mask |= lazy[no].mask;
    tree[no].x = (tree[no].x * modpow(lazy[no].x, j - i + 1, M)) % M;
    int l = no << 1, r = no << 1 | 1;
    if (i != j) {
      lazy[l].mask |= lazy[no].mask;
      lazy[r].mask |= lazy[no].mask;
      lazy[l].x = lazy[l].x * lazy[no].x % M;
      lazy[r].x = lazy[r].x * lazy[no].x % M;
    }
    lazy[no] = node(1, 0);
  }
}
void upd(int no, int i, int j, int a, int b, int v) {
  flush(no, i, j);
  if (i > j or i > b or j < a) return;
  if (a <= i and j <= b) {
    lazy[no] = node(v, Mask[v]);
    flush(no, i, j);
    return;
  }
  int mid = (i + j) >> 1, l = no << 1, r = no << 1 | 1;
  upd(l, i, mid, a, b, v);
  upd(r, mid + 1, j, a, b, v);
  tree[no] = tree[l] + tree[r];
}
node query(int no, int i, int j, int a, int b) {
  if (i > b or j < a) return node(1, 0);
  flush(no, i, j);
  if (a <= i and j <= b) {
    return tree[no];
  }
  int mid = (i + j) >> 1, l = no << 1, r = no << 1 | 1;
  return query(l, i, mid, a, b) + query(r, mid + 1, j, a, b);
}
int rev[P];
long long val[N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int MAX = 0;
  vector<int> primes;
  for (int i = 2; i <= 300; i++) {
    if (is_prime(i)) {
      id[i] = MAX;
      rev[MAX] = i;
      val[MAX] = 1ll * (i - 1) * modpow(i, M - 2, M) % M;
      MAX++;
      primes.push_back(i);
    }
    for (int p : primes) {
      if (i % p == 0) {
        Mask[i] |= (1LL << id[p]);
      }
    }
  }
  int n, q;
  cin >> n >> q;
  for (int i = 1; i < (n + 1); ++i) {
    cin >> a[i];
  }
  build(1, 1, n);
  while (q--) {
    string s;
    cin >> s;
    if (s[0] == 'M') {
      int l, r, x;
      cin >> l >> r >> x;
      upd(1, 1, n, l, r, x);
    } else {
      int l, r;
      cin >> l >> r;
      node R = query(1, 1, n, l, r);
      long long x = R.x;
      long long mask = R.mask;
      for (int i = 0; i < MAX; i++) {
        if ((1LL << i) & mask) {
          x = x * val[i] % M;
        }
      }
      cout << x << "\n";
    }
  }
}
