#include <bits/stdc++.h>
using namespace std;
const int T = 1e9 + 7;
const int maxn = 4e5 + 233;
int p[500], u[500], vis[500], cnt = 0;
void init() {
  memset(vis, 0, sizeof(vis));
  int n = 300;
  u[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!vis[i]) {
      p[++cnt] = i;
      u[i] = -1;
    }
    for (int j = 1; j <= cnt && i * p[j] <= n; j++) {
      if (i % p[j] == 0) {
        u[i * p[j]] = 0;
        vis[i * p[j]] = 1;
        break;
      } else {
        u[i * p[j]] = -u[i];
        vis[i * p[j]] = 1;
      }
    }
  }
  return;
}
int a[maxn];
long long b[maxn], ok;
long long mypow(long long b, int p) {
  long long res = 1;
  while (p) {
    if (p & 1) res = res * b % T;
    b = b * b % T;
    p >>= 1;
  }
  return res;
}
struct seg_tree {
  long long ch[maxn * 4], val[maxn * 4], vis[maxn * 4], flag[maxn * 4];
  inline void push_down(int l, int r, int cur) {
    int mid = (l + r) >> 1, lc = cur << 1, rc = lc | 1;
    val[lc] = val[cur] * val[lc] % T;
    val[rc] = val[cur] * val[rc] % T;
    ch[lc] = ch[lc] * mypow(val[cur], mid - l + 1) % T;
    ch[rc] = ch[rc] * mypow(val[cur], r - mid) % T;
    val[cur] = 1;
    flag[lc] |= flag[cur];
    flag[rc] |= flag[cur];
    vis[lc] |= flag[cur];
    vis[rc] |= flag[cur];
    flag[cur] = 0;
    return;
  }
  void add(int l, int r, int cur, int x, int y, int v, long long s) {
    if (x <= l && r <= y) {
      ch[cur] = ch[cur] * mypow(v, r - l + 1) % T;
      val[cur] = val[cur] * v % T;
      flag[cur] |= s;
      vis[cur] |= s;
      return;
    }
    if (r < x || l > y) return;
    int mid = (l + r) >> 1, lc = cur << 1, rc = lc | 1;
    push_down(l, r, cur);
    add(l, mid, lc, x, y, v, s);
    add(mid + 1, r, rc, x, y, v, s);
    ch[cur] = ch[lc] * ch[rc] % T;
    vis[cur] = vis[lc] | vis[rc];
    return;
  }
  long long query(int l, int r, int cur, int x, int y) {
    if (r < x || l > y) return 1;
    if (x <= l && r <= y) {
      ok |= vis[cur];
      return ch[cur];
    }
    push_down(l, r, cur);
    int mid = (l + r) >> 1, lc = cur << 1, rc = lc | 1;
    return query(l, mid, lc, x, y) * query(mid + 1, r, rc, x, y) % T;
  }
  void build(int l, int r, int cur) {
    if (l == r) {
      ch[cur] = a[l];
      val[cur] = 1;
      vis[cur] = b[l];
      flag[cur] = 0;
      return;
    }
    int mid = (l + r) >> 1, lc = cur << 1, rc = lc | 1;
    build(l, mid, lc);
    build(mid + 1, r, rc);
    ch[cur] = ch[lc] * ch[rc] % T;
    vis[cur] = vis[lc] | vis[rc];
    val[cur] = 1;
  }
} seg;
long long rev[500], ans[maxn];
void exgcd(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return;
  }
  exgcd(b, a % b, y, x);
  y -= (a / b) * x;
}
int main() {
  init();
  for (int i = 1; i <= cnt; i++) {
    int x, y;
    exgcd(p[i], T, x, y);
    x = (x + T) % T;
    rev[i] = 1LL * x * (p[i] - 1) % T;
  }
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    b[i] = 0;
    scanf("%d", &a[i]);
    for (int j = 1; j <= cnt; j++)
      if (a[i] % p[j] == 0) b[i] |= 1LL << (j - 1);
  }
  seg.build(1, n, 1);
  for (int i = 1; i <= m; i++) {
    char s[100];
    int l, r;
    scanf("%s%d%d", s, &l, &r);
    if (s[0] == 'M') {
      int v;
      scanf("%d", &v);
      long long s = 0;
      for (int j = 1; j <= cnt; j++)
        if (v % p[j] == 0) s |= 1LL << (j - 1);
      seg.add(1, n, 1, l, r, v, s);
    } else {
      ok = 0;
      long long ans = seg.query(1, n, 1, l, r);
      for (int j = 0; j < cnt; j++)
        if (ok & (1LL << j)) {
          ans = ans * rev[j + 1] % T;
        }
      printf("%lld\n", ans);
    }
  }
  return 0;
}

### Prompt

In Cpp, your task is to solve the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int T = 1e9 + 7;
const int maxn = 4e5 + 233;
int p[500], u[500], vis[500], cnt = 0;
void init() {
  memset(vis, 0, sizeof(vis));
  int n = 300;
  u[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!vis[i]) {
      p[++cnt] = i;
      u[i] = -1;
    }
    for (int j = 1; j <= cnt && i * p[j] <= n; j++) {
      if (i % p[j] == 0) {
        u[i * p[j]] = 0;
        vis[i * p[j]] = 1;
        break;
      } else {
        u[i * p[j]] = -u[i];
        vis[i * p[j]] = 1;
      }
    }
  }
  return;
}
int a[maxn];
long long b[maxn], ok;
long long mypow(long long b, int p) {
  long long res = 1;
  while (p) {
    if (p & 1) res = res * b % T;
    b = b * b % T;
    p >>= 1;
  }
  return res;
}
struct seg_tree {
  long long ch[maxn * 4], val[maxn * 4], vis[maxn * 4], flag[maxn * 4];
  inline void push_down(int l, int r, int cur) {
    int mid = (l + r) >> 1, lc = cur << 1, rc = lc | 1;
    val[lc] = val[cur] * val[lc] % T;
    val[rc] = val[cur] * val[rc] % T;
    ch[lc] = ch[lc] * mypow(val[cur], mid - l + 1) % T;
    ch[rc] = ch[rc] * mypow(val[cur], r - mid) % T;
    val[cur] = 1;
    flag[lc] |= flag[cur];
    flag[rc] |= flag[cur];
    vis[lc] |= flag[cur];
    vis[rc] |= flag[cur];
    flag[cur] = 0;
    return;
  }
  void add(int l, int r, int cur, int x, int y, int v, long long s) {
    if (x <= l && r <= y) {
      ch[cur] = ch[cur] * mypow(v, r - l + 1) % T;
      val[cur] = val[cur] * v % T;
      flag[cur] |= s;
      vis[cur] |= s;
      return;
    }
    if (r < x || l > y) return;
    int mid = (l + r) >> 1, lc = cur << 1, rc = lc | 1;
    push_down(l, r, cur);
    add(l, mid, lc, x, y, v, s);
    add(mid + 1, r, rc, x, y, v, s);
    ch[cur] = ch[lc] * ch[rc] % T;
    vis[cur] = vis[lc] | vis[rc];
    return;
  }
  long long query(int l, int r, int cur, int x, int y) {
    if (r < x || l > y) return 1;
    if (x <= l && r <= y) {
      ok |= vis[cur];
      return ch[cur];
    }
    push_down(l, r, cur);
    int mid = (l + r) >> 1, lc = cur << 1, rc = lc | 1;
    return query(l, mid, lc, x, y) * query(mid + 1, r, rc, x, y) % T;
  }
  void build(int l, int r, int cur) {
    if (l == r) {
      ch[cur] = a[l];
      val[cur] = 1;
      vis[cur] = b[l];
      flag[cur] = 0;
      return;
    }
    int mid = (l + r) >> 1, lc = cur << 1, rc = lc | 1;
    build(l, mid, lc);
    build(mid + 1, r, rc);
    ch[cur] = ch[lc] * ch[rc] % T;
    vis[cur] = vis[lc] | vis[rc];
    val[cur] = 1;
  }
} seg;
long long rev[500], ans[maxn];
void exgcd(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return;
  }
  exgcd(b, a % b, y, x);
  y -= (a / b) * x;
}
int main() {
  init();
  for (int i = 1; i <= cnt; i++) {
    int x, y;
    exgcd(p[i], T, x, y);
    x = (x + T) % T;
    rev[i] = 1LL * x * (p[i] - 1) % T;
  }
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    b[i] = 0;
    scanf("%d", &a[i]);
    for (int j = 1; j <= cnt; j++)
      if (a[i] % p[j] == 0) b[i] |= 1LL << (j - 1);
  }
  seg.build(1, n, 1);
  for (int i = 1; i <= m; i++) {
    char s[100];
    int l, r;
    scanf("%s%d%d", s, &l, &r);
    if (s[0] == 'M') {
      int v;
      scanf("%d", &v);
      long long s = 0;
      for (int j = 1; j <= cnt; j++)
        if (v % p[j] == 0) s |= 1LL << (j - 1);
      seg.add(1, n, 1, l, r, v, s);
    } else {
      ok = 0;
      long long ans = seg.query(1, n, 1, l, r);
      for (int j = 0; j < cnt; j++)
        if (ok & (1LL << j)) {
          ans = ans * rev[j + 1] % T;
        }
      printf("%lld\n", ans);
    }
  }
  return 0;
}

```