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;
int isp(int n) {
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}
long long int expo(long long int a, long long int b) {
  long long int r = 1;
  a = a % 1000000007;
  while (b) {
    if (b % 2) r = (r * a) % 1000000007;
    a = (a * a) % 1000000007;
    b = b / 2;
  }
  return r;
}
long long int tree[4 * 400010] = {}, a[400010] = {}, lazy[4 * 400010],
                       tree1[4 * 400010], lazy1[4 * 400010], a1[400010];
void build(int l, int r, int node) {
  lazy1[node] = 1;
  if (l == r) {
    tree[node] = a[l];
    tree1[node] = a1[l] % 1000000007;
    return;
  }
  int mid = (l + r) / 2;
  build(l, mid, 2 * node);
  build(mid + 1, r, 2 * node + 1);
  tree[node] = (tree[2 * node] | tree[2 * node + 1]);
  tree1[node] = (tree1[2 * node] * tree1[2 * node + 1]) % 1000000007;
  return;
}
void fun(int l, int r, long long int val, int node) {
  tree[node] = (tree[node] | val);
}
void fun1(int l, int r, long long int val, int node) {
  tree1[node] = (tree1[node] * expo(val, r - l + 1)) % 1000000007;
}
void ul(int l, int r, int node, int st, int en, long long int val) {
  if (lazy[node] != 0) {
    fun(l, r, lazy[node], node);
    if (l != r) {
      lazy[2 * node] = (lazy[2 * node] | lazy[node]);
      lazy[2 * node + 1] = (lazy[2 * node + 1] | lazy[node]);
    }
    lazy[node] = 0;
  }
  if (r < st || en < l)
    return;
  else if (st <= l && en >= r) {
    fun(l, r, val, node);
    if (l != r) {
      lazy[2 * node] = (lazy[2 * node] | val);
      lazy[2 * node + 1] = (lazy[2 * node + 1] | val);
    }
    lazy[node] = 0;
  } else {
    int mid = (l + r) / 2;
    ul(l, mid, 2 * node, st, en, val);
    ul(mid + 1, r, 2 * node + 1, st, en, val);
    tree[node] = (tree[2 * node] | tree[2 * node + 1]);
  }
}
void ul1(int l, int r, int node, int st, int en, long long int val) {
  if (lazy1[node] != 1) {
    fun1(l, r, lazy1[node], node);
    if (l != r) {
      lazy1[2 * node] = (lazy1[2 * node] * lazy1[node]) % 1000000007;
      lazy1[2 * node + 1] = (lazy1[2 * node + 1] * lazy1[node]) % 1000000007;
    }
    lazy1[node] = 1;
  }
  if (r < st || en < l)
    return;
  else if (st <= l && en >= r) {
    fun1(l, r, val, node);
    if (l != r) {
      lazy1[2 * node] = (lazy1[2 * node] * val) % 1000000007;
      lazy1[2 * node + 1] = (lazy1[2 * node + 1] * val) % 1000000007;
    }
    lazy1[node] = 1;
  } else {
    int mid = (l + r) / 2;
    ul1(l, mid, 2 * node, st, en, val);
    ul1(mid + 1, r, 2 * node + 1, st, en, val);
    tree1[node] = (tree1[2 * node] * tree1[2 * node + 1]) % 1000000007;
  }
}
long long int ql(int l, int r, int node, int st, int en) {
  if (r < st || en < l) return 0;
  if (lazy[node] != 0) {
    fun(l, r, lazy[node], node);
    if (l != r) {
      lazy[2 * node] = (lazy[2 * node] | lazy[node]);
      lazy[2 * node + 1] = (lazy[2 * node + 1] | lazy[node]);
    }
    lazy[node] = 0;
  }
  if (st <= l && en >= r)
    return tree[node];
  else {
    int mid = (l + r) / 2;
    return (ql(l, mid, 2 * node, st, en) |
            ql(mid + 1, r, 2 * node + 1, st, en));
  }
}
long long int ql1(int l, int r, int node, int st, int en) {
  if (r < st || en < l) return 1;
  if (lazy1[node] != 1) {
    fun1(l, r, lazy1[node], node);
    if (l != r) {
      lazy1[2 * node] = (lazy1[2 * node] * lazy1[node]) % 1000000007;
      lazy1[2 * node + 1] = (lazy1[2 * node + 1] * lazy1[node]) % 1000000007;
    }
    lazy1[node] = 1;
  }
  if (st <= l && en >= r)
    return tree1[node];
  else {
    int mid = (l + r) / 2;
    return (ql1(l, mid, 2 * node, st, en) *
            ql1(mid + 1, r, 2 * node + 1, st, en)) %
           1000000007;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q;
  cin >> n >> q;
  vector<int> v;
  for (int i = 2; i <= 300; i++) {
    if (isp(i)) v.push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    long long int s = 0;
    for (long long int j = 0; j < v.size(); j++) {
      if (x % v[j] == 0) {
        s += (1ll << j);
      }
    }
    a[i] = s;
    a1[i] = x;
  }
  build(1, n, 1);
  while (q--) {
    string s;
    cin >> s;
    if (s == "MULTIPLY") {
      long long int l, r, x;
      cin >> l >> r >> x;
      long long int s = 0, i = 0;
      while (i < v.size() && v[i] <= x) {
        if (x % v[i] == 0) {
          s += (1ll << i);
        }
        i++;
      }
      ul(1, n, 1, l, r, s);
      ul1(1, n, 1, l, r, x);
    } else {
      long long int l, r;
      cin >> l >> r;
      long long int z = ql(1, n, 1, l, r);
      long long int i = 0;
      long long int x1 = 1, x2 = 1;
      while (z) {
        if (z % 2) {
          x1 = (x1 * v[i]) % 1000000007;
          x2 = (x2 * (v[i] - 1)) % 1000000007;
        }
        z = z / 2;
        i++;
      }
      x1 = expo(x1, 1000000007 - 2);
      cout << (((ql1(1, n, 1, l, r) * x1) % 1000000007) * x2) % 1000000007
           << endl;
    }
  }
  return 0;
}
