#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &x) {
  char c;
  bool op = 0;
  while (c = getchar(), c < '0' || c > '9')
    if (c == '-') op = 1;
  x = c - '0';
  while (c = getchar(), c >= '0' && c <= '9') x = x * 10 + c - '0';
  if (op) x = -x;
}
template <class T>
void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar('0' + x % 10);
}
const int N = 400005, P = 1000000007;
const int pcnt = 62;
const long long prime[] = {
    2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,
    43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101,
    103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
    173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,
    241, 251, 257, 263, 269, 271, 277, 281, 283, 293};
int n, m;
long long d[305], val[305];
long long a[N], ds[4 * N], dd[4 * N], ls[4 * N], ld[4 * N];
char s[105];
long long qpow(long long a, long long x) {
  long long ret = 1;
  while (x) {
    if (x & 1) ret = ret * a % P;
    a = a * a % P;
    x >>= 1;
  }
  return ret;
}
long long calc_d(int x) {
  long long ret = 0;
  for (int i = 0; i < pcnt; i++)
    if (x % prime[i] == 0) ret |= 1LL << i;
  return ret;
}
void init() {
  for (int i = 0; i < pcnt; i++)
    val[i] = (prime[i] - 1) * qpow(prime[i], P - 2) % P;
  for (int i = 1; i <= 300; i++) d[i] = calc_d(i);
}
long long calc_phi(long long x) {
  long long ret = 1;
  for (int i = 0; i < pcnt; i++)
    if (x >> i & 1) ret = ret * val[i] % P;
  return ret;
}
void modify(int k, int l, int r, long long xs, long long xd) {
  ls[k] = ls[k] * xs % P;
  ds[k] = ds[k] * qpow(xs, r - l + 1) % P;
  ld[k] |= xd;
  dd[k] |= xd;
}
void pushdown(int k, int l, int r) {
  if (ls[k] == 1 && !ld[k]) return;
  int mid = (l + r) >> 1;
  modify(k << 1, l, mid, ls[k], ld[k]);
  modify(k << 1 | 1, mid + 1, r, ls[k], ld[k]);
  ls[k] = 1, ld[k] = 0;
}
void pushup(int k) {
  ds[k] = ds[k << 1] * ds[k << 1 | 1] % P;
  dd[k] = dd[k << 1] | dd[k << 1 | 1];
}
void change(int k, int l, int r, int ql, int qr, long long x) {
  if (ql <= l && qr >= r) return modify(k, l, r, x, d[x]);
  pushdown(k, l, r);
  int mid = (l + r) >> 1;
  if (ql <= mid) change(k << 1, l, mid, ql, qr, x);
  if (qr > mid) change(k << 1 | 1, mid + 1, r, ql, qr, x);
  pushup(k);
}
pair<long long, long long> merge(pair<long long, long long> a,
                                 pair<long long, long long> b) {
  return make_pair(a.first * b.first % P, a.second | b.second);
}
pair<long long, long long> query(int k, int l, int r, int ql, int qr) {
  if (ql <= l && qr >= r) return make_pair(ds[k], dd[k]);
  pushdown(k, l, r);
  int mid = (l + r) >> 1;
  pair<long long, long long> ret = make_pair(1, 0);
  if (ql <= mid) ret = query(k << 1, l, mid, ql, qr);
  if (qr > mid) ret = merge(ret, query(k << 1 | 1, mid + 1, r, ql, qr));
  return ret;
}
void build(int k, int l, int r) {
  ls[k] = 1, ld[k] = 0;
  if (l == r) return (void)(ds[k] = a[l], dd[k] = d[a[l]]);
  int mid = (l + r) >> 1;
  build(k << 1, l, mid);
  build(k << 1 | 1, mid + 1, r);
  pushup(k);
}
void out(long long x) {
  putchar('\n');
  for (int i = 0; i < pcnt; i++) putchar('0' + (x >> i & 1));
  putchar('\n');
}
int main() {
  init();
  read(n), read(m);
  for (int i = 1; i <= n; i++) read(a[i]);
  build(1, 1, n);
  int l, r;
  long long x;
  while (m--) {
    scanf("%s", s);
    if (s[0] == 'M') {
      read(l), read(r), read(x);
      change(1, 1, n, l, r, x);
    } else {
      read(l), read(r);
      pair<long long, long long> res = query(1, 1, n, l, r);
      write(res.first * calc_phi(res.second) % P), putchar('\n');
    }
  }
  return 0;
}

### Prompt

Generate 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;
template <class T>
void read(T &x) {
  char c;
  bool op = 0;
  while (c = getchar(), c < '0' || c > '9')
    if (c == '-') op = 1;
  x = c - '0';
  while (c = getchar(), c >= '0' && c <= '9') x = x * 10 + c - '0';
  if (op) x = -x;
}
template <class T>
void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar('0' + x % 10);
}
const int N = 400005, P = 1000000007;
const int pcnt = 62;
const long long prime[] = {
    2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,
    43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101,
    103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
    173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,
    241, 251, 257, 263, 269, 271, 277, 281, 283, 293};
int n, m;
long long d[305], val[305];
long long a[N], ds[4 * N], dd[4 * N], ls[4 * N], ld[4 * N];
char s[105];
long long qpow(long long a, long long x) {
  long long ret = 1;
  while (x) {
    if (x & 1) ret = ret * a % P;
    a = a * a % P;
    x >>= 1;
  }
  return ret;
}
long long calc_d(int x) {
  long long ret = 0;
  for (int i = 0; i < pcnt; i++)
    if (x % prime[i] == 0) ret |= 1LL << i;
  return ret;
}
void init() {
  for (int i = 0; i < pcnt; i++)
    val[i] = (prime[i] - 1) * qpow(prime[i], P - 2) % P;
  for (int i = 1; i <= 300; i++) d[i] = calc_d(i);
}
long long calc_phi(long long x) {
  long long ret = 1;
  for (int i = 0; i < pcnt; i++)
    if (x >> i & 1) ret = ret * val[i] % P;
  return ret;
}
void modify(int k, int l, int r, long long xs, long long xd) {
  ls[k] = ls[k] * xs % P;
  ds[k] = ds[k] * qpow(xs, r - l + 1) % P;
  ld[k] |= xd;
  dd[k] |= xd;
}
void pushdown(int k, int l, int r) {
  if (ls[k] == 1 && !ld[k]) return;
  int mid = (l + r) >> 1;
  modify(k << 1, l, mid, ls[k], ld[k]);
  modify(k << 1 | 1, mid + 1, r, ls[k], ld[k]);
  ls[k] = 1, ld[k] = 0;
}
void pushup(int k) {
  ds[k] = ds[k << 1] * ds[k << 1 | 1] % P;
  dd[k] = dd[k << 1] | dd[k << 1 | 1];
}
void change(int k, int l, int r, int ql, int qr, long long x) {
  if (ql <= l && qr >= r) return modify(k, l, r, x, d[x]);
  pushdown(k, l, r);
  int mid = (l + r) >> 1;
  if (ql <= mid) change(k << 1, l, mid, ql, qr, x);
  if (qr > mid) change(k << 1 | 1, mid + 1, r, ql, qr, x);
  pushup(k);
}
pair<long long, long long> merge(pair<long long, long long> a,
                                 pair<long long, long long> b) {
  return make_pair(a.first * b.first % P, a.second | b.second);
}
pair<long long, long long> query(int k, int l, int r, int ql, int qr) {
  if (ql <= l && qr >= r) return make_pair(ds[k], dd[k]);
  pushdown(k, l, r);
  int mid = (l + r) >> 1;
  pair<long long, long long> ret = make_pair(1, 0);
  if (ql <= mid) ret = query(k << 1, l, mid, ql, qr);
  if (qr > mid) ret = merge(ret, query(k << 1 | 1, mid + 1, r, ql, qr));
  return ret;
}
void build(int k, int l, int r) {
  ls[k] = 1, ld[k] = 0;
  if (l == r) return (void)(ds[k] = a[l], dd[k] = d[a[l]]);
  int mid = (l + r) >> 1;
  build(k << 1, l, mid);
  build(k << 1 | 1, mid + 1, r);
  pushup(k);
}
void out(long long x) {
  putchar('\n');
  for (int i = 0; i < pcnt; i++) putchar('0' + (x >> i & 1));
  putchar('\n');
}
int main() {
  init();
  read(n), read(m);
  for (int i = 1; i <= n; i++) read(a[i]);
  build(1, 1, n);
  int l, r;
  long long x;
  while (m--) {
    scanf("%s", s);
    if (s[0] == 'M') {
      read(l), read(r), read(x);
      change(1, 1, n, l, r, x);
    } else {
      read(l), read(r);
      pair<long long, long long> res = query(1, 1, n, l, r);
      write(res.first * calc_phi(res.second) % P), putchar('\n');
    }
  }
  return 0;
}

```