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;
long long mod = 1000000007;
struct node {
  long long lazy, sum;
  long long mul, lz, ck;
} tree[400005 * 4];
long long sum[400005 * 4];
long long lazy[400005 * 4];
long long arr[400005];
long long on = 1;
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};
long long bigmod(long long a, long long b) {
  if (b == 0) return 1 % mod;
  long long x = bigmod(a, b / 2);
  x = (x * x) % mod;
  if (b & 1) x = (x * a) % mod;
  return x;
}
long long F(long long n) {
  long long x = 0LL;
  for (int i = 0; i < 62; i++) {
    if (n % prime[i] == 0) {
      x |= (1LL << i);
    }
  }
  return x;
}
void init1(int n, int b, int e) {
  if (b == e) {
    tree[n].sum = F(arr[b]);
    tree[n].lazy = 0;
    return;
  }
  int mid = (b + e) / 2;
  init1(n * 2, b, mid);
  init1(n * 2 + 1, mid + 1, e);
  tree[n].ck = 1;
  tree[n].sum = (tree[n * 2].sum | tree[n * 2 + 1].sum);
  tree[n].lazy = 0;
}
void update1(int n, int b, int e, int l, int r, long long val) {
  if (tree[n].ck == 0) {
    tree[n].sum |= tree[n].lazy;
    if (b != e) {
      tree[n * 2].ck = tree[n * 2 + 1].ck = 0;
      tree[n * 2].lazy |= tree[n].lazy;
      tree[n * 2 + 1].lazy |= tree[n].lazy;
    }
    tree[n].ck = 1;
  }
  if (b > r || l > e) return;
  if (b >= l && e <= r) {
    long long x = F(val);
    tree[n].sum |= x;
    if (b != e) {
      tree[n * 2].ck = tree[n * 2 + 1].ck = 0;
      tree[n * 2].lazy |= x;
      tree[n * 2 + 1].lazy |= x;
    }
    return;
  }
  int mid = (b + e) / 2;
  update1(n * 2, b, mid, l, r, val);
  update1(n * 2 + 1, mid + 1, e, l, r, val);
  tree[n].sum = (tree[n * 2].sum | tree[n * 2 + 1].sum);
}
long long query1(int n, int b, int e, int l, int r) {
  if (tree[n].ck == 0) {
    tree[n].sum |= tree[n].lazy;
    if (b != e) {
      tree[n * 2].ck = tree[n * 2 + 1].ck = 0;
      tree[n * 2].lazy |= tree[n].lazy;
      tree[n * 2 + 1].lazy |= tree[n].lazy;
    }
    tree[n].ck = 1;
  }
  if (b > r || l > e) return 0;
  if (b >= l && e <= r) {
    return tree[n].sum;
  }
  int mid = (b + e) / 2;
  long long x1, x2, x3;
  x1 = query1(n * 2, b, mid, l, r);
  x2 = query1(n * 2 + 1, mid + 1, e, l, r);
  return x1 | x2;
}
void init(int n, int b, int e) {
  if (b == e) {
    tree[n].mul = arr[b];
    tree[n].lz = on;
    return;
  }
  int mid = (b + e) / 2;
  init(n * 2, b, mid);
  init(n * 2 + 1, mid + 1, e);
  tree[n].mul = (tree[n * 2].mul * tree[n * 2 + 1].mul) % mod;
  tree[n].lz = on;
}
void update(int n, int b, int e, int l, int r, long long v) {
  if (tree[n].lz != 1) {
    long long xx = bigmod(tree[n].lz, e - b + 1);
    tree[n].mul *= xx;
    tree[n].mul %= mod;
    if (b != e) {
      tree[n * 2].lz *= tree[n].lz;
      tree[n * 2].lz %= mod;
      tree[n * 2 + 1].lz *= tree[n].lz;
      tree[n * 2 + 1].lz %= mod;
    }
    tree[n].lz = 1;
  }
  if (b > r || l > e) return;
  if (b >= l && e <= r) {
    long long xx = bigmod(v, e - b + 1);
    tree[n].mul *= xx;
    tree[n].mul %= mod;
    if (b != e) {
      tree[n * 2].lz *= v;
      tree[n * 2].lz %= mod;
      tree[n * 2 + 1].lz *= v;
      tree[n * 2 + 1].lz %= mod;
    }
    return;
  }
  int mid = (b + e) / 2;
  update(n * 2, b, mid, l, r, v);
  update(n * 2 + 1, mid + 1, e, l, r, v);
  tree[n].mul = (tree[n * 2].mul * tree[n * 2 + 1].mul) % mod;
}
long long query(int n, int b, int e, int l, int r) {
  if (tree[n].lz != 1) {
    long long xx = bigmod(tree[n].lz, e - b + 1);
    tree[n].mul *= xx;
    tree[n].mul %= mod;
    if (b != e) {
      tree[n * 2].lz *= tree[n].lz;
      tree[n * 2].lz %= mod;
      tree[n * 2 + 1].lz *= tree[n].lz;
      tree[n * 2 + 1].lz %= mod;
    }
    tree[n].lz = 1;
  }
  if (b > r || l > e) return 1LL;
  if (b >= l && e <= r) {
    return tree[n].mul;
  };
  int mid = (b + e) / 2;
  long long x1, x2;
  x1 = query(n * 2, b, mid, l, r) % mod;
  x2 = query(n * 2 + 1, mid + 1, e, l, r) % mod;
  return (long long)(x1 * x2) % mod;
}
long long inv[65];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  for (int i = 0; i < 62; i++) {
    inv[i] = bigmod(prime[i], mod - 2);
  }
  int n, m, l, r;
  string st;
  long long x, y, z, xx, yy, zz, v;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  init(1, 1, n);
  init1(1, 1, n);
  while (m--) {
    cin >> st;
    if (st[0] == 'M') {
      cin >> l >> r >> v;
      update(1, 1, n, l, r, v);
      update1(1, 1, n, l, r, v);
    } else {
      cin >> l >> r;
      yy = query(1, 1, n, l, r);
      xx = query1(1, 1, n, l, r);
      z = 1LL;
      for (int i = 0; i < 62; i++) {
        if (xx & (1LL << i)) {
          x = inv[i];
          x = ((1 - x) % mod + mod) % mod;
          z = (x * z) % mod;
        }
      }
      cout << (z * yy) % mod << endl;
    }
  }
  return 0;
}
