#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  long long pos = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') pos = 0;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
  return pos ? x : -x;
}
const long long N = 500001;
long long mod = 1000000007;
long long n, q, a[N];
long long val[N << 2], tag[N << 2], val1[N << 2], tag1[N << 2], pri[N], vis[N],
    inv[N], f[N], pl;
long long ksm(long long aa, long long bb) {
  long long cc = 1;
  while (bb) {
    if (bb & 1) {
      cc = cc * aa % mod;
    }
    aa = aa * aa % mod;
    bb >>= 1;
  }
  return cc;
}
void push_down(long long now) {
  if (tag[now]) {
    val[now << 1] |= tag[now];
    val[now << 1 | 1] |= tag[now];
    tag[now << 1] |= tag[now];
    tag[now << 1 | 1] |= tag[now];
    tag[now] = 0;
  }
}
void push_down1(long long now, long long l, long long r) {
  if (tag1[now] != 1ll) {
    long long mid = (l + r) >> 1;
    val1[now << 1] = val1[now << 1] * ksm(tag1[now], (mid - l + 1)) % mod;
    val1[now << 1 | 1] = val1[now << 1 | 1] * ksm(tag1[now], (r - mid)) % mod;
    tag1[now << 1] = tag1[now << 1] * tag1[now] % mod;
    tag1[now << 1 | 1] = tag1[now << 1 | 1] * tag1[now] % mod;
    tag1[now] = 1ll;
  }
}
void insert(long long now, long long l, long long r, long long pos,
            long long sta) {
  val[now] |= sta;
  if (l == r) return;
  long long mid = (l + r) >> 1;
  if (pos <= mid)
    insert(now << 1, l, mid, pos, sta);
  else
    insert(now << 1 | 1, mid + 1, r, pos, sta);
}
void insert1(long long now, long long l, long long r, long long pos,
             long long w) {
  if (tag1[now] == 0) tag1[now] = 1ll;
  if (val1[now] == 0) val1[now] = 1ll;
  val1[now] = val1[now] * w % mod;
  if (l == r) return;
  long long mid = (l + r) >> 1;
  if (pos <= mid)
    insert1(now << 1, l, mid, pos, w);
  else
    insert1(now << 1 | 1, mid + 1, r, pos, w);
}
long long query(long long now, long long l, long long r, long long ql,
                long long qr) {
  if (ql <= l && r <= qr) return val[now];
  long long mid = (l + r) >> 1;
  push_down(now);
  long long ans = 0;
  if (ql <= mid) ans |= query(now << 1, l, mid, ql, qr);
  if (mid < qr) ans |= query(now << 1 | 1, mid + 1, r, ql, qr);
  return ans;
}
long long query1(long long now, long long l, long long r, long long ql,
                 long long qr) {
  if (ql <= l && r <= qr) return val1[now];
  long long mid = (l + r) >> 1;
  push_down1(now, l, r);
  long long ans = 1ll;
  if (ql <= mid) ans = ans * query1(now << 1, l, mid, ql, qr) % mod;
  if (mid < qr) ans = ans * query1(now << 1 | 1, mid + 1, r, ql, qr) % mod;
  return ans;
}
void push_up(long long now) { val[now] = val[now << 1] | val[now << 1 | 1]; }
void push_up1(long long now) {
  val1[now] = val1[now << 1] * val1[now << 1 | 1] % mod;
}
void change(long long now, long long l, long long r, long long ql, long long qr,
            long long sta) {
  if (ql <= l && r <= qr) {
    val[now] |= sta;
    tag[now] |= sta;
    return;
  }
  push_down(now);
  long long mid = (l + r) >> 1;
  if (ql <= mid) change(now << 1, l, mid, ql, qr, sta);
  if (mid < qr) change(now << 1 | 1, mid + 1, r, ql, qr, sta);
  push_up(now);
}
void change1(long long now, long long l, long long r, long long ql,
             long long qr, long long w) {
  if (ql <= l && r <= qr) {
    val1[now] = val1[now] * ksm(w, (r - l + 1)) % mod;
    tag1[now] = tag1[now] * w % mod;
    return;
  }
  push_down1(now, l, r);
  long long mid = (l + r) >> 1;
  if (ql <= mid) change1(now << 1, l, mid, ql, qr, w);
  if (mid < qr) change1(now << 1 | 1, mid + 1, r, ql, qr, w);
  push_up1(now);
}
char s[10];
int main() {
  n = read(), q = read();
  for (register long long i = (2); i <= (300); ++i) {
    if (!vis[i]) pri[++pl] = i;
    for (long long j = 1; j <= pl && i * pri[j] <= 300; j++) {
      vis[i * pri[j]] = 1;
      if (i % pri[j] == 0) break;
    }
  }
  inv[1] = 1;
  for (register long long i = (2); i <= (300); ++i)
    inv[i] = mod - 1ll * (mod / i) * inv[mod % i] % mod;
  for (register long long i = (1); i <= (pl); ++i)
    f[i] = 1ll * inv[pri[i]] * (pri[i] - 1) % mod;
  for (register long long i = (1); i <= (n); ++i) {
    a[i] = read();
    long long sta = 0;
    for (long long j = 1; j <= pl; j++) {
      if (a[i] % pri[j] == 0) sta |= (1ll << (j - 1));
    }
    insert(1, 1, n, i, sta);
    insert1(1, 1, n, i, a[i]);
  }
  long long l, r, x;
  for (register long long i = (1); i <= (q); ++i) {
    scanf("%s", s);
    l = read(), r = read();
    if (s[0] == 'T') {
      long long nsta = query(1, 1, n, l, r);
      long long phi = query1(1, 1, n, l, r);
      for (long long j = 1; j <= pl; j++) {
        if (nsta & (1ll << (j - 1))) {
          phi = phi * f[j] % mod;
        }
      }
      printf("%lld\n", phi);
    } else {
      x = read();
      long long sta = 0;
      for (long long j = 1; j <= pl; j++) {
        if (x % pri[j] == 0) sta |= (1ll << (j - 1));
      }
      change(1, 1, n, l, r, sta);
      change1(1, 1, n, l, r, x);
    }
  }
  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;
inline long long read() {
  long long x = 0;
  long long pos = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') pos = 0;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
  return pos ? x : -x;
}
const long long N = 500001;
long long mod = 1000000007;
long long n, q, a[N];
long long val[N << 2], tag[N << 2], val1[N << 2], tag1[N << 2], pri[N], vis[N],
    inv[N], f[N], pl;
long long ksm(long long aa, long long bb) {
  long long cc = 1;
  while (bb) {
    if (bb & 1) {
      cc = cc * aa % mod;
    }
    aa = aa * aa % mod;
    bb >>= 1;
  }
  return cc;
}
void push_down(long long now) {
  if (tag[now]) {
    val[now << 1] |= tag[now];
    val[now << 1 | 1] |= tag[now];
    tag[now << 1] |= tag[now];
    tag[now << 1 | 1] |= tag[now];
    tag[now] = 0;
  }
}
void push_down1(long long now, long long l, long long r) {
  if (tag1[now] != 1ll) {
    long long mid = (l + r) >> 1;
    val1[now << 1] = val1[now << 1] * ksm(tag1[now], (mid - l + 1)) % mod;
    val1[now << 1 | 1] = val1[now << 1 | 1] * ksm(tag1[now], (r - mid)) % mod;
    tag1[now << 1] = tag1[now << 1] * tag1[now] % mod;
    tag1[now << 1 | 1] = tag1[now << 1 | 1] * tag1[now] % mod;
    tag1[now] = 1ll;
  }
}
void insert(long long now, long long l, long long r, long long pos,
            long long sta) {
  val[now] |= sta;
  if (l == r) return;
  long long mid = (l + r) >> 1;
  if (pos <= mid)
    insert(now << 1, l, mid, pos, sta);
  else
    insert(now << 1 | 1, mid + 1, r, pos, sta);
}
void insert1(long long now, long long l, long long r, long long pos,
             long long w) {
  if (tag1[now] == 0) tag1[now] = 1ll;
  if (val1[now] == 0) val1[now] = 1ll;
  val1[now] = val1[now] * w % mod;
  if (l == r) return;
  long long mid = (l + r) >> 1;
  if (pos <= mid)
    insert1(now << 1, l, mid, pos, w);
  else
    insert1(now << 1 | 1, mid + 1, r, pos, w);
}
long long query(long long now, long long l, long long r, long long ql,
                long long qr) {
  if (ql <= l && r <= qr) return val[now];
  long long mid = (l + r) >> 1;
  push_down(now);
  long long ans = 0;
  if (ql <= mid) ans |= query(now << 1, l, mid, ql, qr);
  if (mid < qr) ans |= query(now << 1 | 1, mid + 1, r, ql, qr);
  return ans;
}
long long query1(long long now, long long l, long long r, long long ql,
                 long long qr) {
  if (ql <= l && r <= qr) return val1[now];
  long long mid = (l + r) >> 1;
  push_down1(now, l, r);
  long long ans = 1ll;
  if (ql <= mid) ans = ans * query1(now << 1, l, mid, ql, qr) % mod;
  if (mid < qr) ans = ans * query1(now << 1 | 1, mid + 1, r, ql, qr) % mod;
  return ans;
}
void push_up(long long now) { val[now] = val[now << 1] | val[now << 1 | 1]; }
void push_up1(long long now) {
  val1[now] = val1[now << 1] * val1[now << 1 | 1] % mod;
}
void change(long long now, long long l, long long r, long long ql, long long qr,
            long long sta) {
  if (ql <= l && r <= qr) {
    val[now] |= sta;
    tag[now] |= sta;
    return;
  }
  push_down(now);
  long long mid = (l + r) >> 1;
  if (ql <= mid) change(now << 1, l, mid, ql, qr, sta);
  if (mid < qr) change(now << 1 | 1, mid + 1, r, ql, qr, sta);
  push_up(now);
}
void change1(long long now, long long l, long long r, long long ql,
             long long qr, long long w) {
  if (ql <= l && r <= qr) {
    val1[now] = val1[now] * ksm(w, (r - l + 1)) % mod;
    tag1[now] = tag1[now] * w % mod;
    return;
  }
  push_down1(now, l, r);
  long long mid = (l + r) >> 1;
  if (ql <= mid) change1(now << 1, l, mid, ql, qr, w);
  if (mid < qr) change1(now << 1 | 1, mid + 1, r, ql, qr, w);
  push_up1(now);
}
char s[10];
int main() {
  n = read(), q = read();
  for (register long long i = (2); i <= (300); ++i) {
    if (!vis[i]) pri[++pl] = i;
    for (long long j = 1; j <= pl && i * pri[j] <= 300; j++) {
      vis[i * pri[j]] = 1;
      if (i % pri[j] == 0) break;
    }
  }
  inv[1] = 1;
  for (register long long i = (2); i <= (300); ++i)
    inv[i] = mod - 1ll * (mod / i) * inv[mod % i] % mod;
  for (register long long i = (1); i <= (pl); ++i)
    f[i] = 1ll * inv[pri[i]] * (pri[i] - 1) % mod;
  for (register long long i = (1); i <= (n); ++i) {
    a[i] = read();
    long long sta = 0;
    for (long long j = 1; j <= pl; j++) {
      if (a[i] % pri[j] == 0) sta |= (1ll << (j - 1));
    }
    insert(1, 1, n, i, sta);
    insert1(1, 1, n, i, a[i]);
  }
  long long l, r, x;
  for (register long long i = (1); i <= (q); ++i) {
    scanf("%s", s);
    l = read(), r = read();
    if (s[0] == 'T') {
      long long nsta = query(1, 1, n, l, r);
      long long phi = query1(1, 1, n, l, r);
      for (long long j = 1; j <= pl; j++) {
        if (nsta & (1ll << (j - 1))) {
          phi = phi * f[j] % mod;
        }
      }
      printf("%lld\n", phi);
    } else {
      x = read();
      long long sta = 0;
      for (long long j = 1; j <= pl; j++) {
        if (x % pri[j] == 0) sta |= (1ll << (j - 1));
      }
      change(1, 1, n, l, r, sta);
      change1(1, 1, n, l, r, x);
    }
  }
  return 0;
}

```