#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5, M = 300, MOD = 1e9 + 7;
int n, m, a[N];
int t[4 * N], ob[4 * N];
void build(int v, int l, int r) {
  ob[v] = 1;
  if (l == r) {
    t[v] = a[l];
    return;
  }
  int mid = (r + l) >> 1;
  build(v + v, l, mid);
  build(v + v + 1, mid + 1, r);
  t[v] = 1LL * t[v + v] * t[v + v + 1] % MOD;
}
inline int binpow(int a, int n) {
  int res = 1;
  while (n) {
    if (n & 1) {
      res = 1LL * res * a % MOD;
    }
    a = 1LL * a * a % MOD;
    n >>= 1;
  }
  return res;
}
inline void push(int v, int l, int r) {
  if (ob[v] != 1) {
    ob[v + v] = 1LL * ob[v + v] * ob[v] % MOD;
    ob[v + v + 1] = 1LL * ob[v + v + 1] * ob[v] % MOD;
    int mid = (r + l) >> 1;
    t[v + v] = 1LL * t[v + v] * binpow(ob[v], mid - l + 1) % MOD;
    t[v + v + 1] = 1LL * t[v + v + 1] * binpow(ob[v], r - mid) % MOD;
    ob[v] = 1;
  }
}
void update(int v, int l, int r, int tl, int tr, int x) {
  if (l > r || l > tr || tl > r) {
    return;
  }
  if (tl <= l && r <= tr) {
    t[v] = 1LL * t[v] * binpow(x, r - l + 1) % MOD;
    ob[v] = 1LL * ob[v] * x % MOD;
    return;
  }
  push(v, l, r);
  int mid = (r + l) >> 1;
  update(v + v, l, mid, tl, tr, x);
  update(v + v + 1, mid + 1, r, tl, tr, x);
  t[v] = 1LL * t[v + v] * t[v + v + 1] % MOD;
}
int get(int v, int l, int r, int tl, int tr) {
  if (l > r || l > tr || tl > r) {
    return 1;
  }
  if (tl <= l && r <= tr) {
    return t[v];
  }
  push(v, l, r);
  int mid = (r + l) >> 1;
  return 1LL * get(v + v, l, mid, tl, tr) * get(v + v + 1, mid + 1, r, tl, tr) %
         MOD;
}
vector<int> pr, rev_pr;
inline bool prime(int x) {
  if (x == 1) {
    return false;
  }
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
struct segment_tree {
  bitset<4 * N> f, ob;
  segment_tree() {}
  void push(int v) {
    if (ob[v]) {
      ob[v + v] = true;
      ob[v + v + 1] = true;
      f[v + v] = true;
      f[v + v + 1] = true;
      ob[v] = 0;
    }
  }
  void update(int v, int l, int r, int tl, int tr) {
    if (l > r || l > tr || tl > r) {
      return;
    }
    if (tl <= l && r <= tr) {
      f[v] = true;
      ob[v] = true;
      return;
    }
    push(v);
    int mid = (r + l) >> 1;
    update(v + v, l, mid, tl, tr);
    update(v + v + 1, mid + 1, r, tl, tr);
    f[v] = (f[v + v] | f[v + v + 1]);
  }
  bool get(int v, int l, int r, int tl, int tr) {
    if (l > r || l > tr || tl > r) {
      return false;
    }
    if (tl <= l && r <= tr) {
      return f[v];
    }
    push(v);
    int mid = (r + l) >> 1;
    return (get(v + v, l, mid, tl, tr) | get(v + v + 1, mid + 1, r, tl, tr));
  }
};
segment_tree rt[62];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 1; i <= 300; i++) {
    if (prime(i)) {
      pr.push_back(i);
      rev_pr.push_back(binpow(i, MOD - 2));
    }
  }
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 0; j < (int)pr.size(); j++) {
      if (a[i] % pr[j] == 0) {
        rt[j].update(1, 1, n, i, i);
      }
    }
  }
  build(1, 1, n);
  while (m--) {
    string type;
    cin >> type;
    if (type[0] == 'M') {
      int l, r, x;
      cin >> l >> r >> x;
      update(1, 1, n, l, r, x);
      for (int i = 0; i < (int)pr.size(); i++) {
        if (x % pr[i] == 0) {
          rt[i].update(1, 1, n, l, r);
        }
      }
    } else {
      int l, r;
      cin >> l >> r;
      int val = get(1, 1, n, l, r);
      for (int i = 0; i < (int)pr.size(); i++) {
        if (rt[i].get(1, 1, n, l, r) > 0) {
          val = 1LL * val * (pr[i] - 1) % MOD;
          val = 1LL * val * rev_pr[i] % MOD;
        }
      }
      cout << val << "\n";
    }
  }
}

### Prompt

Please formulate a CPP solution to 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 N = 4e5 + 5, M = 300, MOD = 1e9 + 7;
int n, m, a[N];
int t[4 * N], ob[4 * N];
void build(int v, int l, int r) {
  ob[v] = 1;
  if (l == r) {
    t[v] = a[l];
    return;
  }
  int mid = (r + l) >> 1;
  build(v + v, l, mid);
  build(v + v + 1, mid + 1, r);
  t[v] = 1LL * t[v + v] * t[v + v + 1] % MOD;
}
inline int binpow(int a, int n) {
  int res = 1;
  while (n) {
    if (n & 1) {
      res = 1LL * res * a % MOD;
    }
    a = 1LL * a * a % MOD;
    n >>= 1;
  }
  return res;
}
inline void push(int v, int l, int r) {
  if (ob[v] != 1) {
    ob[v + v] = 1LL * ob[v + v] * ob[v] % MOD;
    ob[v + v + 1] = 1LL * ob[v + v + 1] * ob[v] % MOD;
    int mid = (r + l) >> 1;
    t[v + v] = 1LL * t[v + v] * binpow(ob[v], mid - l + 1) % MOD;
    t[v + v + 1] = 1LL * t[v + v + 1] * binpow(ob[v], r - mid) % MOD;
    ob[v] = 1;
  }
}
void update(int v, int l, int r, int tl, int tr, int x) {
  if (l > r || l > tr || tl > r) {
    return;
  }
  if (tl <= l && r <= tr) {
    t[v] = 1LL * t[v] * binpow(x, r - l + 1) % MOD;
    ob[v] = 1LL * ob[v] * x % MOD;
    return;
  }
  push(v, l, r);
  int mid = (r + l) >> 1;
  update(v + v, l, mid, tl, tr, x);
  update(v + v + 1, mid + 1, r, tl, tr, x);
  t[v] = 1LL * t[v + v] * t[v + v + 1] % MOD;
}
int get(int v, int l, int r, int tl, int tr) {
  if (l > r || l > tr || tl > r) {
    return 1;
  }
  if (tl <= l && r <= tr) {
    return t[v];
  }
  push(v, l, r);
  int mid = (r + l) >> 1;
  return 1LL * get(v + v, l, mid, tl, tr) * get(v + v + 1, mid + 1, r, tl, tr) %
         MOD;
}
vector<int> pr, rev_pr;
inline bool prime(int x) {
  if (x == 1) {
    return false;
  }
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
struct segment_tree {
  bitset<4 * N> f, ob;
  segment_tree() {}
  void push(int v) {
    if (ob[v]) {
      ob[v + v] = true;
      ob[v + v + 1] = true;
      f[v + v] = true;
      f[v + v + 1] = true;
      ob[v] = 0;
    }
  }
  void update(int v, int l, int r, int tl, int tr) {
    if (l > r || l > tr || tl > r) {
      return;
    }
    if (tl <= l && r <= tr) {
      f[v] = true;
      ob[v] = true;
      return;
    }
    push(v);
    int mid = (r + l) >> 1;
    update(v + v, l, mid, tl, tr);
    update(v + v + 1, mid + 1, r, tl, tr);
    f[v] = (f[v + v] | f[v + v + 1]);
  }
  bool get(int v, int l, int r, int tl, int tr) {
    if (l > r || l > tr || tl > r) {
      return false;
    }
    if (tl <= l && r <= tr) {
      return f[v];
    }
    push(v);
    int mid = (r + l) >> 1;
    return (get(v + v, l, mid, tl, tr) | get(v + v + 1, mid + 1, r, tl, tr));
  }
};
segment_tree rt[62];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 1; i <= 300; i++) {
    if (prime(i)) {
      pr.push_back(i);
      rev_pr.push_back(binpow(i, MOD - 2));
    }
  }
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 0; j < (int)pr.size(); j++) {
      if (a[i] % pr[j] == 0) {
        rt[j].update(1, 1, n, i, i);
      }
    }
  }
  build(1, 1, n);
  while (m--) {
    string type;
    cin >> type;
    if (type[0] == 'M') {
      int l, r, x;
      cin >> l >> r >> x;
      update(1, 1, n, l, r, x);
      for (int i = 0; i < (int)pr.size(); i++) {
        if (x % pr[i] == 0) {
          rt[i].update(1, 1, n, l, r);
        }
      }
    } else {
      int l, r;
      cin >> l >> r;
      int val = get(1, 1, n, l, r);
      for (int i = 0; i < (int)pr.size(); i++) {
        if (rt[i].get(1, 1, n, l, r) > 0) {
          val = 1LL * val * (pr[i] - 1) % MOD;
          val = 1LL * val * rev_pr[i] % MOD;
        }
      }
      cout << val << "\n";
    }
  }
}

```