#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 100;
const long long mod = 1e9 + 7;
bool is_pri[310];
int pri[310];
int cnt = 0;
int rtl[maxn << 2], rtr[maxn << 2], rtv[maxn << 2], lazy[maxn << 2];
long long rtn[maxn << 2], lazy1[maxn << 2];
int pre_pri[310];
int qmod(int a, int b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    b >>= 1;
    a = 1LL * a * a % mod;
  }
  return ans;
}
void Pri() {
  for (int i = 2; i <= 300; ++i) {
    if (!is_pri[i]) {
      pre_pri[cnt] = qmod(i, mod - 2);
      pri[cnt++] = i;
    }
    for (int j = 0; j < cnt && i * pri[j] <= 300; ++j) {
      is_pri[i * pri[j]] = 1;
      if (i % pri[j] == 0) break;
    }
  }
}
void push_down(int p) {
  if (lazy[p] > 1 || lazy1[p]) {
    int p1 = p << 1 | 1, p2 = (p << 1) + 2;
    lazy[p1] = 1LL * lazy[p1] * lazy[p] % mod;
    lazy[p2] = 1LL * lazy[p2] * lazy[p] % mod;
    rtv[p1] = 1LL * rtv[p1] * qmod(lazy[p], rtr[p1] - rtl[p1] + 1) % mod;
    rtv[p2] = 1LL * rtv[p2] * qmod(lazy[p], rtr[p2] - rtl[p2] + 1) % mod;
    lazy[p] = 1;
    lazy1[p1] |= lazy1[p];
    lazy1[p2] |= lazy1[p];
    rtn[p1] |= lazy1[p];
    rtn[p2] |= lazy1[p];
    lazy1[p] = 0;
  }
}
void push_up(int p) {
  int p1 = p << 1 | 1, p2 = (p << 1) + 2;
  rtv[p] = 1LL * rtv[p1] * rtv[p2] % mod;
  rtn[p] = rtn[p1] | rtn[p2];
}
void build(int l, int r, int p) {
  rtl[p] = l, rtr[p] = r;
  rtv[p] = 1;
  lazy[p] = 1;
  rtn[p] = lazy1[p] = 0;
  if (l >= r) return;
  build(l, (l + r) / 2, p << 1 | 1);
  build((l + r) / 2 + 1, r, (p << 1) + 2);
}
void update(int l, int r, int v, long long v1, int p) {
  if (rtl[p] >= l && r >= rtr[p]) {
    lazy[p] = 1LL * lazy[p] * v % mod;
    lazy1[p] |= v1;
    rtv[p] = 1LL * rtv[p] * qmod(v, (rtr[p] - rtl[p] + 1)) % mod;
    rtn[p] |= v1;
    return;
  }
  push_down(p);
  int mid = (rtr[p] + rtl[p]) / 2;
  if (l <= mid) {
    update(l, r, v, v1, p << 1 | 1);
  }
  if (r > mid) {
    update(l, r, v, v1, (p << 1) + 2);
  }
  push_up(p);
}
int query(int l, int r, int p, long long &v1) {
  if (rtl[p] >= l && rtr[p] <= r) {
    v1 |= rtn[p];
    return rtv[p];
  }
  push_down(p);
  int mid = (rtr[p] + rtl[p]) / 2;
  long long ans = 1;
  if (l <= mid) {
    ans = ans * query(l, r, p << 1 | 1, v1) % mod;
  }
  if (r > mid) {
    ans = ans * query(l, r, (p << 1) + 2, v1) % mod;
  }
  return ans;
}
int a[maxn];
void insert(int l, int r, int tmp) {
  int v = 1;
  long long v1 = 0;
  for (int i = 0; i < cnt; ++i) {
    if (pri[i] > tmp) break;
    if (tmp % pri[i] == 0) {
      v1 |= 1LL << i;
      while (tmp % pri[i] == 0) {
        tmp /= pri[i];
        v *= pri[i];
      }
    }
  }
  update(l, r, v, v1, 0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Pri();
  int n, q;
  cin >> n >> q;
  build(0, n - 1, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    insert(i, i, a[i]);
  }
  string s;
  int l, r, tmp;
  while (q--) {
    cin >> s;
    if (s[0] == 'M') {
      cin >> l >> r >> tmp;
      --l, --r;
      insert(l, r, tmp);
    } else {
      cin >> l >> r;
      --l, --r;
      long long v1 = 0;
      long long ans = query(l, r, 0, v1);
      if (v1) {
        for (int i = 0; i < cnt; ++i) {
          if ((1LL << i) & v1) {
            ans = ans * pre_pri[i] % mod * (pri[i] - 1) % mod;
          }
        }
      }
      cout << ans << endl;
    }
  }
}

### Prompt

Develop a solution in cpp to the problem described below:

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 maxn = 4e5 + 100;
const long long mod = 1e9 + 7;
bool is_pri[310];
int pri[310];
int cnt = 0;
int rtl[maxn << 2], rtr[maxn << 2], rtv[maxn << 2], lazy[maxn << 2];
long long rtn[maxn << 2], lazy1[maxn << 2];
int pre_pri[310];
int qmod(int a, int b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    b >>= 1;
    a = 1LL * a * a % mod;
  }
  return ans;
}
void Pri() {
  for (int i = 2; i <= 300; ++i) {
    if (!is_pri[i]) {
      pre_pri[cnt] = qmod(i, mod - 2);
      pri[cnt++] = i;
    }
    for (int j = 0; j < cnt && i * pri[j] <= 300; ++j) {
      is_pri[i * pri[j]] = 1;
      if (i % pri[j] == 0) break;
    }
  }
}
void push_down(int p) {
  if (lazy[p] > 1 || lazy1[p]) {
    int p1 = p << 1 | 1, p2 = (p << 1) + 2;
    lazy[p1] = 1LL * lazy[p1] * lazy[p] % mod;
    lazy[p2] = 1LL * lazy[p2] * lazy[p] % mod;
    rtv[p1] = 1LL * rtv[p1] * qmod(lazy[p], rtr[p1] - rtl[p1] + 1) % mod;
    rtv[p2] = 1LL * rtv[p2] * qmod(lazy[p], rtr[p2] - rtl[p2] + 1) % mod;
    lazy[p] = 1;
    lazy1[p1] |= lazy1[p];
    lazy1[p2] |= lazy1[p];
    rtn[p1] |= lazy1[p];
    rtn[p2] |= lazy1[p];
    lazy1[p] = 0;
  }
}
void push_up(int p) {
  int p1 = p << 1 | 1, p2 = (p << 1) + 2;
  rtv[p] = 1LL * rtv[p1] * rtv[p2] % mod;
  rtn[p] = rtn[p1] | rtn[p2];
}
void build(int l, int r, int p) {
  rtl[p] = l, rtr[p] = r;
  rtv[p] = 1;
  lazy[p] = 1;
  rtn[p] = lazy1[p] = 0;
  if (l >= r) return;
  build(l, (l + r) / 2, p << 1 | 1);
  build((l + r) / 2 + 1, r, (p << 1) + 2);
}
void update(int l, int r, int v, long long v1, int p) {
  if (rtl[p] >= l && r >= rtr[p]) {
    lazy[p] = 1LL * lazy[p] * v % mod;
    lazy1[p] |= v1;
    rtv[p] = 1LL * rtv[p] * qmod(v, (rtr[p] - rtl[p] + 1)) % mod;
    rtn[p] |= v1;
    return;
  }
  push_down(p);
  int mid = (rtr[p] + rtl[p]) / 2;
  if (l <= mid) {
    update(l, r, v, v1, p << 1 | 1);
  }
  if (r > mid) {
    update(l, r, v, v1, (p << 1) + 2);
  }
  push_up(p);
}
int query(int l, int r, int p, long long &v1) {
  if (rtl[p] >= l && rtr[p] <= r) {
    v1 |= rtn[p];
    return rtv[p];
  }
  push_down(p);
  int mid = (rtr[p] + rtl[p]) / 2;
  long long ans = 1;
  if (l <= mid) {
    ans = ans * query(l, r, p << 1 | 1, v1) % mod;
  }
  if (r > mid) {
    ans = ans * query(l, r, (p << 1) + 2, v1) % mod;
  }
  return ans;
}
int a[maxn];
void insert(int l, int r, int tmp) {
  int v = 1;
  long long v1 = 0;
  for (int i = 0; i < cnt; ++i) {
    if (pri[i] > tmp) break;
    if (tmp % pri[i] == 0) {
      v1 |= 1LL << i;
      while (tmp % pri[i] == 0) {
        tmp /= pri[i];
        v *= pri[i];
      }
    }
  }
  update(l, r, v, v1, 0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Pri();
  int n, q;
  cin >> n >> q;
  build(0, n - 1, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    insert(i, i, a[i]);
  }
  string s;
  int l, r, tmp;
  while (q--) {
    cin >> s;
    if (s[0] == 'M') {
      cin >> l >> r >> tmp;
      --l, --r;
      insert(l, r, tmp);
    } else {
      cin >> l >> r;
      --l, --r;
      long long v1 = 0;
      long long ans = query(l, r, 0, v1);
      if (v1) {
        for (int i = 0; i < cnt; ++i) {
          if ((1LL << i) & v1) {
            ans = ans * pre_pri[i] % mod * (pri[i] - 1) % mod;
          }
        }
      }
      cout << ans << endl;
    }
  }
}

```