#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 4e5 + 10;
int a[maxn], n, q;
long long pri[] = {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};
long long ni[65];
long long pow_mod(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return ans;
}
struct tree {
  int left, right;
  long long sum, add;
  long long pos, lz;
} c[maxn << 2];
void build(int id, int l, int r) {
  c[id].left = l;
  c[id].right = r;
  c[id].add = 1;
  c[id].lz = 0;
  if (l == r) {
    c[id].sum = a[l];
    for (long long i = 0; i < 62; ++i) {
      if (a[l] % pri[i] == 0) {
        c[id].pos = (c[id].pos | (1ll << i));
        a[l] /= pri[i];
        while (a[l] % pri[i] == 0) a[l] /= pri[i];
      }
      if (a[l] < pri[i]) break;
    }
    return;
  }
  int mid = (l + r) >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid + 1, r);
  c[id].pos = ((c[id << 1].pos) | (c[id << 1 | 1].pos));
  c[id].sum = (c[id << 1].sum * c[id << 1 | 1].sum) % mod;
}
void pushdown(int id) {
  c[id << 1].sum =
      (c[id << 1].sum *
       pow_mod(c[id].add, (c[id << 1].right - c[id << 1].left + 1), mod)) %
      mod;
  c[id << 1 | 1].sum =
      (c[id << 1 | 1].sum *
       pow_mod(c[id].add, (c[id << 1 | 1].right - c[id << 1 | 1].left + 1),
               mod)) %
      mod;
  c[id << 1].add = c[id << 1].add * c[id].add % mod;
  c[id << 1 | 1].add = c[id << 1 | 1].add * c[id].add % mod;
  c[id].add = 1;
  c[id << 1].pos = (c[id << 1].pos | c[id].lz);
  c[id << 1 | 1].pos = (c[id << 1 | 1].pos | c[id].lz);
  c[id << 1].lz = (c[id << 1].lz | c[id].lz);
  c[id << 1 | 1].lz = (c[id << 1 | 1].lz | c[id].lz);
  c[id].lz = 0;
}
void update(int id, int l, int r, long long v, long long p) {
  if (c[id].left > r || c[id].right < l) return;
  if (c[id].left >= l && c[id].right <= r) {
    c[id].sum =
        (pow_mod(v, (c[id].right - c[id].left + 1), mod) * c[id].sum) % mod;
    c[id].add = (c[id].add * v) % mod;
    c[id].pos = (c[id].pos | p);
    c[id].lz = (p | c[id].lz);
    return;
  }
  if (c[id].add > 1) pushdown(id);
  if (c[id].lz) pushdown(id);
  update(id << 1, l, r, v, p);
  update(id << 1 | 1, l, r, v, p);
  c[id].sum = c[id << 1].sum * c[id << 1 | 1].sum % mod;
  c[id].pos = (c[id << 1].pos | c[id << 1 | 1].pos);
}
long long query_sum(int id, int l, int r) {
  if (r < c[id].left || l > c[id].right) return 1;
  if (c[id].left >= l && c[id].right <= r) {
    return c[id].sum;
  }
  if (c[id].add > 1) pushdown(id);
  long long ans = query_sum(id << 1, l, r) * query_sum(id << 1 | 1, l, r) % mod;
  c[id].sum = c[id << 1].sum * c[id << 1 | 1].sum % mod;
  return ans;
}
long long query_pos(int id, int l, int r) {
  if (r < c[id].left || l > c[id].right) return 0;
  if (c[id].left >= l && c[id].right <= r) {
    return c[id].pos;
  }
  if (c[id].lz) pushdown(id);
  long long pos = (query_pos(id << 1, l, r) | query_pos(id << 1 | 1, l, r));
  c[id].pos = (c[id << 1].pos | c[id << 1 | 1].pos);
  return pos;
}
char s[10];
int main() {
  for (int i = 0; i < 62; ++i) {
    ni[i] = pow_mod(pri[i], mod - 2, mod);
  }
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  build(1, 1, n);
  int l, r, x;
  long long ans, p;
  while (q--) {
    scanf("%s", s);
    if (s[0] == 'T') {
      scanf("%d%d", &l, &r);
      ans = query_sum(1, l, r);
      p = query_pos(1, l, r);
      for (long long i = 0; i < 62; ++i) {
        if ((p & (1ll << i)) != 0) {
          ans = ans * ni[i] % mod;
          ans = ans * (pri[i] - 1) % mod;
        }
      }
      printf("%lld\n", ans);
    } else {
      scanf("%d%d%d", &l, &r, &x);
      long long p = 0;
      long long v = x;
      for (long long i = 0; i < 62; ++i) {
        if (v % pri[i] == 0) {
          p = (p | (1ll << i));
          v /= pri[i];
          while (v % pri[i] == 0) v /= pri[i];
        }
        if (pri[i] > v) break;
      }
      update(1, l, r, x, p);
    }
  }
  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;
const long long mod = 1e9 + 7;
const int maxn = 4e5 + 10;
int a[maxn], n, q;
long long pri[] = {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};
long long ni[65];
long long pow_mod(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return ans;
}
struct tree {
  int left, right;
  long long sum, add;
  long long pos, lz;
} c[maxn << 2];
void build(int id, int l, int r) {
  c[id].left = l;
  c[id].right = r;
  c[id].add = 1;
  c[id].lz = 0;
  if (l == r) {
    c[id].sum = a[l];
    for (long long i = 0; i < 62; ++i) {
      if (a[l] % pri[i] == 0) {
        c[id].pos = (c[id].pos | (1ll << i));
        a[l] /= pri[i];
        while (a[l] % pri[i] == 0) a[l] /= pri[i];
      }
      if (a[l] < pri[i]) break;
    }
    return;
  }
  int mid = (l + r) >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid + 1, r);
  c[id].pos = ((c[id << 1].pos) | (c[id << 1 | 1].pos));
  c[id].sum = (c[id << 1].sum * c[id << 1 | 1].sum) % mod;
}
void pushdown(int id) {
  c[id << 1].sum =
      (c[id << 1].sum *
       pow_mod(c[id].add, (c[id << 1].right - c[id << 1].left + 1), mod)) %
      mod;
  c[id << 1 | 1].sum =
      (c[id << 1 | 1].sum *
       pow_mod(c[id].add, (c[id << 1 | 1].right - c[id << 1 | 1].left + 1),
               mod)) %
      mod;
  c[id << 1].add = c[id << 1].add * c[id].add % mod;
  c[id << 1 | 1].add = c[id << 1 | 1].add * c[id].add % mod;
  c[id].add = 1;
  c[id << 1].pos = (c[id << 1].pos | c[id].lz);
  c[id << 1 | 1].pos = (c[id << 1 | 1].pos | c[id].lz);
  c[id << 1].lz = (c[id << 1].lz | c[id].lz);
  c[id << 1 | 1].lz = (c[id << 1 | 1].lz | c[id].lz);
  c[id].lz = 0;
}
void update(int id, int l, int r, long long v, long long p) {
  if (c[id].left > r || c[id].right < l) return;
  if (c[id].left >= l && c[id].right <= r) {
    c[id].sum =
        (pow_mod(v, (c[id].right - c[id].left + 1), mod) * c[id].sum) % mod;
    c[id].add = (c[id].add * v) % mod;
    c[id].pos = (c[id].pos | p);
    c[id].lz = (p | c[id].lz);
    return;
  }
  if (c[id].add > 1) pushdown(id);
  if (c[id].lz) pushdown(id);
  update(id << 1, l, r, v, p);
  update(id << 1 | 1, l, r, v, p);
  c[id].sum = c[id << 1].sum * c[id << 1 | 1].sum % mod;
  c[id].pos = (c[id << 1].pos | c[id << 1 | 1].pos);
}
long long query_sum(int id, int l, int r) {
  if (r < c[id].left || l > c[id].right) return 1;
  if (c[id].left >= l && c[id].right <= r) {
    return c[id].sum;
  }
  if (c[id].add > 1) pushdown(id);
  long long ans = query_sum(id << 1, l, r) * query_sum(id << 1 | 1, l, r) % mod;
  c[id].sum = c[id << 1].sum * c[id << 1 | 1].sum % mod;
  return ans;
}
long long query_pos(int id, int l, int r) {
  if (r < c[id].left || l > c[id].right) return 0;
  if (c[id].left >= l && c[id].right <= r) {
    return c[id].pos;
  }
  if (c[id].lz) pushdown(id);
  long long pos = (query_pos(id << 1, l, r) | query_pos(id << 1 | 1, l, r));
  c[id].pos = (c[id << 1].pos | c[id << 1 | 1].pos);
  return pos;
}
char s[10];
int main() {
  for (int i = 0; i < 62; ++i) {
    ni[i] = pow_mod(pri[i], mod - 2, mod);
  }
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  build(1, 1, n);
  int l, r, x;
  long long ans, p;
  while (q--) {
    scanf("%s", s);
    if (s[0] == 'T') {
      scanf("%d%d", &l, &r);
      ans = query_sum(1, l, r);
      p = query_pos(1, l, r);
      for (long long i = 0; i < 62; ++i) {
        if ((p & (1ll << i)) != 0) {
          ans = ans * ni[i] % mod;
          ans = ans * (pri[i] - 1) % mod;
        }
      }
      printf("%lld\n", ans);
    } else {
      scanf("%d%d%d", &l, &r, &x);
      long long p = 0;
      long long v = x;
      for (long long i = 0; i < 62; ++i) {
        if (v % pri[i] == 0) {
          p = (p | (1ll << i));
          v /= pri[i];
          while (v % pri[i] == 0) v /= pri[i];
        }
        if (pri[i] > v) break;
      }
      update(1, l, r, x, p);
    }
  }
  return 0;
}

```