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.
#include <bits/stdc++.h>
using namespace std;
namespace input {
const int InputBufferSize = (1 << 24) + 5;
char buffer[InputBufferSize], *s, *eof;
inline void init() {
  assert(stdin != NULL);
  s = buffer;
  eof = s + fread(buffer, 1, InputBufferSize, stdin);
}
inline bool read(int& x) {
  x = 0;
  int flag = 1;
  while (!isdigit(*s) && *s != '-') s++;
  if (eof <= s) return false;
  if (*s == '-') flag = -1, s++;
  while (isdigit(*s)) x = x * 10 + *s++ - '0';
  x *= flag;
  return true;
}
inline bool read(char* str) {
  *str = 0;
  while (isspace(*s)) s++;
  if (eof < s) return false;
  while (!isspace(*s)) *str = 0, *str = *s, str++, s++;
  *str = 0;
  return true;
}
}  // namespace input
using namespace input;
int const p = 1e9 + 7;
int pr[305], cnt, a[400005], tmp[65], id[305], c[305], tree[1600005],
    tag[1600005];
long long b[400005], tree2[1600005], tag2[1600005];
bool flag[305];
long long res(int x) {
  memset(tmp, 0, sizeof(tmp));
  long long res = 0;
  for (int i = 0; i <= 6; i++)
    while (!(x % pr[i])) x /= pr[i], res |= (1ll << i);
  if (x != 1) res |= (1ll << id[x]);
  return res;
}
int pw(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = 1ll * res * x % p;
    x = 1ll * x * x % p;
    y >>= 1;
  }
  return res;
}
void build(int l, int r, int x) {
  if (l == r) {
    tree[x] = a[l];
    tag[x] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, x * 2), build(mid + 1, r, x * 2 + 1);
  tree[x] = 1ll * tree[x * 2] * tree[x * 2 + 1] % p;
  tag[x] = 1;
}
void build2(int l, int r, int x) {
  if (l == r) {
    tree2[x] = b[l];
    return;
  }
  int mid = (l + r) >> 1;
  build2(l, mid, x * 2), build2(mid + 1, r, x * 2 + 1);
  tree2[x] = (tree2[x * 2] | tree2[x * 2 + 1]);
}
void pushdown(int l, int r, int x) {
  if (tag[x] == 1) return;
  tree[x] = 1ll * tree[x] * pw(tag[x], r - l + 1) % p;
  if (l != r)
    tag[x * 2] = 1ll * tag[x * 2] * tag[x] % p,
            tag[x * 2 + 1] = 1ll * tag[x * 2 + 1] * tag[x] % p;
  tag[x] = 1;
}
void modify(int l, int r, int x, int a, int b, int c) {
  if (l >= a && r <= b) {
    tag[x] = 1ll * tag[x] * c % p;
    return;
  }
  int mid = (l + r) >> 1;
  if (a <= mid) modify(l, mid, x * 2, a, b, c);
  if (b > mid) modify(mid + 1, r, x * 2 + 1, a, b, c);
  pushdown(l, mid, x * 2), pushdown(mid + 1, r, x * 2 + 1);
  tree[x] = 1ll * tree[x * 2] * tree[x * 2 + 1] % p;
}
void pushdown2(int l, int r, int x) {
  if (!tag2[x]) return;
  tree2[x] |= tag2[x];
  if (l != r) tag2[x * 2] |= tag2[x], tag2[x * 2 + 1] |= tag2[x];
  tag2[x] = 0;
}
void modify2(int l, int r, int x, int a, int b, long long c) {
  if (l >= a && r <= b) {
    tag2[x] = (tag2[x] | c);
    return;
  }
  int mid = (l + r) >> 1;
  if (a <= mid) modify2(l, mid, x * 2, a, b, c);
  if (b > mid) modify2(mid + 1, r, x * 2 + 1, a, b, c);
  pushdown2(l, mid, x * 2), pushdown2(mid + 1, r, x * 2 + 1);
  tree2[x] = (tree2[x * 2] | tree2[x * 2 + 1]);
}
int ask(int l, int r, int x, int a, int b) {
  pushdown(l, r, x);
  if (l >= a && r <= b) return tree[x];
  int mid = (l + r) >> 1, res = 1;
  if (a <= mid) res = ask(l, mid, x * 2, a, b);
  if (b > mid) res = 1ll * res * ask(mid + 1, r, x * 2 + 1, a, b) % p;
  return res;
}
long long ask2(int l, int r, int x, int a, int b) {
  pushdown2(l, r, x);
  if (l >= a && r <= b) return tree2[x];
  int mid = (l + r) >> 1;
  long long res = 0;
  if (a <= mid) res = ask2(l, mid, x * 2, a, b);
  if (b > mid) res = (res | ask2(mid + 1, r, x * 2 + 1, a, b));
  return res;
}
char op[15];
int main() {
  for (int i = 2; i <= 300; i++) {
    if (!flag[i])
      pr[cnt] = i, id[i] = cnt, c[cnt] = 1ll * (i - 1) * pw(i, p - 2) % p,
      cnt++;
    for (int j = i * 2; j <= 300; j += i) flag[j] = 1;
  }
  init();
  int n, q, l, r, x;
  long long y;
  read(n), read(q);
  for (int i = 1; i <= n; i++) {
    read(a[i]);
    b[i] = res(a[i]);
  }
  build(1, n, 1), build2(1, n, 1);
  while (q--) {
    read(op);
    if (op[0] == 'M') {
      read(l), read(r), read(x);
      y = res(x);
      modify(1, n, 1, l, r, x), modify2(1, n, 1, l, r, y);
    } else {
      read(l), read(r);
      x = ask(1, n, 1, l, r), y = ask2(1, n, 1, l, r);
      for (int j = 0; j <= 61; j++)
        if (y & (1ll << j)) x = 1ll * x * c[j] % p;
      printf("%d\n", x);
    }
  }
  return 0;
}
