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>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
using namespace std;
const int N = 4e5 + 10;
const int MOD = 1e9 + 7;
struct Node {
  long long a, b;
  long long la, lb;
} tree[N << 2];
int n, q, a[N], l, r, x;
int prime[62] = {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 inv[62];
inline long long q_pow(long long n, long long k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}
inline void push_up(int rt) {
  tree[rt].a = tree[rt << 1].a * tree[rt << 1 | 1].a % MOD;
  tree[rt].b = tree[rt << 1].b | tree[rt << 1 | 1].b;
}
inline void push_down(int rt, int len) {
  tree[rt << 1].a =
      tree[rt << 1].a * q_pow(tree[rt].la, len - (len >> 1)) % MOD;
  tree[rt << 1 | 1].a =
      tree[rt << 1 | 1].a * q_pow(tree[rt].la, len >> 1) % MOD;
  tree[rt << 1].b |= tree[rt].lb;
  tree[rt << 1 | 1].b |= tree[rt].lb;
  tree[rt << 1].la = tree[rt << 1].la * tree[rt].la % MOD;
  tree[rt << 1 | 1].la = tree[rt << 1 | 1].la * tree[rt].la % MOD;
  tree[rt << 1].lb |= tree[rt].lb;
  tree[rt << 1 | 1].lb |= tree[rt].lb;
  tree[rt].la = 1;
  tree[rt].lb = 0;
}
inline void build(int rt, int l, int r) {
  tree[rt].la = 1;
  tree[rt].lb = 0;
  if (l == r) {
    tree[rt].a = a[l];
    tree[rt].b = 0;
    for (int j = 0; j < 62; ++j)
      if (a[l] % prime[j] == 0) tree[rt].b |= 1LL << j;
    return;
  }
  int m = l + r >> 1;
  build(rt << 1, l, m);
  build(rt << 1 | 1, m + 1, r);
  push_up(rt);
}
inline void update(int L, int R, int x, long long st, int rt, int l, int r) {
  if (L <= l && r <= R) {
    tree[rt].a = tree[rt].a * q_pow(x, r - l + 1) % MOD;
    tree[rt].la = tree[rt].la * x % MOD;
    tree[rt].b |= st;
    tree[rt].lb |= st;
    return;
  }
  if (tree[rt].lb) push_down(rt, r - l + 1);
  int m = l + r >> 1;
  if (L <= m) update(L, R, x, st, rt << 1, l, m);
  if (R > m) update(L, R, x, st, rt << 1 | 1, m + 1, r);
  push_up(rt);
}
inline pair<long long, long long> query(int L, int R, int rt, int l, int r) {
  if (L <= l && r <= R) return {tree[rt].a, tree[rt].b};
  int m = l + r >> 1;
  pair<long long, long long> res = {1, 0};
  if (tree[rt].lb) push_down(rt, r - l + 1);
  if (L <= m) {
    pair<long long, long long> tmp = query(L, R, rt << 1, l, m);
    res.first = res.first * tmp.first % MOD;
    res.second |= tmp.second;
  }
  if (R > m) {
    pair<long long, long long> tmp = query(L, R, rt << 1 | 1, m + 1, r);
    res.first = res.first * tmp.first % MOD;
    res.second |= tmp.second;
  }
  push_up(rt);
  return res;
}
char op[20];
int main() {
  for (int i = 0; i < 62; ++i) inv[i] = q_pow(prime[i], MOD - 2);
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  build(1, 1, n);
  for (int i = 1; i <= q; ++i) {
    scanf("%s", op);
    if (op[0] == 'M') {
      scanf("%d %d %d", &l, &r, &x);
      long long st = 0;
      for (int j = 0; j < 62; ++j)
        if (x % prime[j] == 0) st |= 1LL << j;
      update(l, r, x, st, 1, 1, n);
    } else {
      scanf("%d %d", &l, &r);
      pair<long long, long long> tmp = query(l, r, 1, 1, n);
      long long res = tmp.first;
      for (int j = 0; j < 62; ++j) {
        if (tmp.second & (1LL << j)) {
          res = res * inv[j] % MOD;
          res = res * (prime[j] - 1) % MOD;
        }
      }
      printf("%lld\n", res);
    }
  }
  return 0;
}
