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 md = 1e9 + 7;
inline int mul(int a, int b) { return (int)((long long)a * b % md); }
inline int sub(int a, int b) {
  a -= b;
  if (a < 0) return a + md;
  return a;
}
inline int po(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline int inv(int a) { return po(a, md - 2); }
const int X = 300;
const int P = 62;
int p[P], lp[X + 1];
long long fact[X + 1];
int inver[P];
void prime_init() {
  int size = 0;
  memset(lp, -1, (X + 1) * 4);
  for (int i = 2; i <= X; ++i) {
    if (lp[i] == -1) {
      lp[i] = size;
      p[size] = i;
      ++size;
    }
    for (int j = 0; j < size && p[j] <= p[lp[i]] && i * p[j] <= X; ++j)
      lp[i * p[j]] = j;
  }
}
void fact_init() {
  for (int i = 1; i <= X; ++i) {
    int t = i;
    while (t != 1) {
      fact[i] |= (long long)1 << lp[t];
      t /= p[lp[t]];
    }
  }
}
void inv_init() {
  for (int i = 0; i < P; ++i) inver[i] = inv(p[i]);
}
const int N = 400000;
int a[N];
struct SegmentTree {
  vector<pair<int, long long> > t;
  vector<pair<int, long long> > upd;
  SegmentTree(int n) {
    t.resize(1 << (33 - __builtin_clz(n - 1)));
    upd.resize(1 << (33 - __builtin_clz(n - 1)), pair<int, long long>(1, 0));
    build(0, 0, n - 1);
  }
  void build(int v, int tl, int tr);
  void push(int v, int tl, int tr);
  void update(int v, int tl, int tr, int l, int r, int val);
  pair<int, long long> query(int v, int tl, int tr, int l, int r);
};
void SegmentTree::build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v].first = a[tl];
    t[v].second = fact[a[tl]];
  } else {
    build(v * 2 + 1, tl, (tl + tr) / 2);
    build(v * 2 + 2, (tl + tr) / 2 + 1, tr);
    t[v].first = mul(t[v * 2 + 1].first, t[v * 2 + 2].first);
    t[v].second = t[v * 2 + 1].second | t[v * 2 + 2].second;
  }
}
void SegmentTree::push(int v, int tl, int tr) {
  if (upd[v].second) {
    t[v].first = mul(t[v].first, po(upd[v].first, tr - tl + 1));
    t[v].second |= upd[v].second;
    if (tl != tr) {
      upd[v * 2 + 1].first = mul(upd[v * 2 + 1].first, upd[v].first);
      upd[v * 2 + 2].first = mul(upd[v * 2 + 2].first, upd[v].first);
      upd[v * 2 + 1].second |= upd[v].second;
      upd[v * 2 + 2].second |= upd[v].second;
    }
    upd[v].first = 1;
    upd[v].second = 0;
  }
}
void SegmentTree::update(int v, int tl, int tr, int l, int r, int val) {
  if (tr < l || tl > r)
    push(v, tl, tr);
  else if (tl >= l && tr <= r) {
    upd[v].first = mul(upd[v].first, val);
    upd[v].second |= fact[val];
    push(v, tl, tr);
  } else {
    push(v, tl, tr);
    update(v * 2 + 1, tl, (tl + tr) / 2, l, r, val);
    update(v * 2 + 2, (tl + tr) / 2 + 1, tr, l, r, val);
    t[v].first = mul(t[v * 2 + 1].first, t[v * 2 + 2].first);
    t[v].second = t[v * 2 + 1].second | t[v * 2 + 2].second;
  }
}
pair<int, long long> SegmentTree::query(int v, int tl, int tr, int l, int r) {
  if (tr < l || tl > r) return make_pair((int)1, (long long)0);
  push(v, tl, tr);
  if (tl >= l && tr <= r) return t[v];
  pair<int, long long> ansl = query(v * 2 + 1, tl, (tl + tr) / 2, l, r);
  pair<int, long long> ansr = query(v * 2 + 2, (tl + tr) / 2 + 1, tr, l, r);
  ansl.first = mul(ansl.first, ansr.first);
  ansl.second |= ansr.second;
  return ansl;
}
int totient(pair<int, long long> x) {
  for (int i = 0; i < P; ++i)
    if (((long long)1 << i) & x.second)
      x.first = mul(x.first, 1 - inver[i] + md);
  return x.first;
}
int main() {
  prime_init();
  fact_init();
  inv_init();
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  SegmentTree tr(n);
  char qtype[9];
  int l, r;
  while (q--) {
    scanf("%s%d%d", qtype, &l, &r);
    if (!strcmp(qtype, "TOTIENT")) {
      pair<int, long long> qans = tr.query(0, 0, n - 1, l - 1, r - 1);
      printf("%d\n", totient(qans));
    } else {
      int val;
      scanf("%d", &val);
      tr.update(0, 0, n - 1, l - 1, r - 1, val);
    }
  }
  return 0;
}
