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;
const char endLine = '\n';
const int LIMIT = 400 * 1000 + 10;
const long long MOD = 1000 * 1000 * 1000 + 7;
const int BOUND = 300 + 5;
const long long one = 1LL;
int n;
int arr[LIMIT];
long long proTree[5 * LIMIT];
long long proLazy[5 * LIMIT];
long long maskTree[5 * LIMIT];
long long maskLazy[5 * LIMIT];
long long mask[5 * LIMIT];
long long invPow[100];
vector<int> primes;
bool isPrime(int val) {
  if (val < 2) {
    return false;
  }
  for (int i = 2; i * i <= val; i++) {
    if (val % i == 0) {
      return false;
    }
  }
  return true;
}
long long powMod(long long N, long long M, long long MOD) {
  long long res = 1;
  while (M > 0) {
    if (M % 2 == 0) {
      N = (1LL * N * N) % MOD;
      M /= 2;
    } else {
      res = (1LL * res * N) % MOD;
      M -= 1;
    }
  }
  return res;
}
void shift_tree(int node, int nodeStartIndex, int nodeEndIndex) {
  if (proLazy[node] != 1) {
    int mid = (nodeStartIndex + nodeEndIndex) / 2;
    proTree[2 * node] = proTree[2 * node] *
                        powMod(proLazy[node], mid - nodeStartIndex + 1, MOD) %
                        MOD;
    proTree[2 * node + 1] = proTree[2 * node + 1] *
                            powMod(proLazy[node], nodeEndIndex - mid, MOD) %
                            MOD;
    proLazy[node * 2] = proLazy[node * 2] * proLazy[node] % MOD;
    proLazy[node * 2 + 1] = proLazy[node * 2 + 1] * proLazy[node] % MOD;
    proLazy[node] = 1;
  }
  if (maskLazy[node] != 0) {
    maskTree[2 * node] = maskTree[2 * node] | maskLazy[node];
    maskTree[2 * node + 1] = maskTree[2 * node + 1] | maskLazy[node];
    maskLazy[node * 2] = maskLazy[node * 2] | maskLazy[node];
    maskLazy[node * 2 + 1] = maskLazy[node * 2 + 1] | maskLazy[node];
    maskLazy[node] = 0;
  }
}
void build_tree(int node, int nodeStartIndex, int nodeEndIndex) {
  if (nodeStartIndex > nodeEndIndex) return;
  if (nodeStartIndex == nodeEndIndex) {
    proTree[node] = arr[nodeStartIndex];
    maskTree[node] = mask[arr[nodeStartIndex]];
    return;
  }
  build_tree(node * 2, nodeStartIndex, (nodeStartIndex + nodeEndIndex) / 2);
  build_tree(node * 2 + 1, 1 + (nodeStartIndex + nodeEndIndex) / 2,
             nodeEndIndex);
  proTree[node] = proTree[node * 2] * proTree[node * 2 + 1] % MOD;
  maskTree[node] = maskTree[node * 2] | maskTree[node * 2 + 1];
}
void update_tree(int node, int nodeStartIndex, int nodeEndIndex,
                 int queryStartIndex, int queryEndIndex, int value) {
  if (nodeStartIndex > nodeEndIndex || nodeStartIndex > queryEndIndex ||
      nodeEndIndex < queryStartIndex) {
    return;
  }
  if (nodeStartIndex >= queryStartIndex && nodeEndIndex <= queryEndIndex) {
    proTree[node] = proTree[node] *
                    powMod(value, nodeEndIndex - nodeStartIndex + 1, MOD) % MOD;
    proLazy[node] = proLazy[node] * value % MOD;
    maskTree[node] = maskTree[node] | mask[value];
    maskLazy[node] = maskLazy[node] | mask[value];
    return;
  }
  shift_tree(node, nodeStartIndex, nodeEndIndex);
  update_tree(node * 2, nodeStartIndex, (nodeStartIndex + nodeEndIndex) / 2,
              queryStartIndex, queryEndIndex, value);
  update_tree(node * 2 + 1, 1 + (nodeStartIndex + nodeEndIndex) / 2,
              nodeEndIndex, queryStartIndex, queryEndIndex, value);
  proTree[node] = proTree[node * 2] * proTree[node * 2 + 1] % MOD;
  maskTree[node] = maskTree[node * 2] | maskTree[node * 2 + 1];
}
pair<long long, long long> query_tree(int node, int nodeStartIndex,
                                      int nodeEndIndex, int queryStartIndex,
                                      int queryEndIndex) {
  if (nodeStartIndex > nodeEndIndex || nodeStartIndex > queryEndIndex ||
      nodeEndIndex < queryStartIndex) {
    return make_pair(1, 0);
  }
  if (nodeStartIndex >= queryStartIndex && nodeEndIndex <= queryEndIndex) {
    return make_pair(proTree[node], maskTree[node]);
  }
  shift_tree(node, nodeStartIndex, nodeEndIndex);
  pair<long long, long long> q1 =
      query_tree(node * 2, nodeStartIndex, (nodeStartIndex + nodeEndIndex) / 2,
                 queryStartIndex, queryEndIndex);
  pair<long long, long long> q2 =
      query_tree(1 + node * 2, 1 + (nodeStartIndex + nodeEndIndex) / 2,
                 nodeEndIndex, queryStartIndex, queryEndIndex);
  return make_pair(q1.first * q2.first % MOD, q1.second | q2.second);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  int q;
  cin >> q;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 2; i < BOUND; i++) {
    if (isPrime(i)) {
      primes.push_back(i);
    }
  }
  for (int i = 0; i < primes.size(); i++) {
    invPow[i] = powMod(primes[i], MOD - 2, MOD);
  }
  for (int i = 1; i < LIMIT; i++) {
    long long m = 0;
    for (int j = 0; j < primes.size(); j++) {
      if (i % primes[j] == 0) {
        m += 1LL << j;
      }
    }
    mask[i] = m;
  }
  for (int i = 0; i < 5 * LIMIT; i++) {
    proLazy[i] = 1;
    maskLazy[i] = 0;
  }
  build_tree(1, 0, n - 1);
  for (int i = 0; i < q; i++) {
    string command;
    cin >> command;
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    if (command == "MULTIPLY") {
      int x;
      cin >> x;
      update_tree(1, 0, n - 1, l, r, x);
    } else {
      pair<long long, long long> p = query_tree(1, 0, n - 1, l, r);
      long long res = p.first;
      long long m = p.second;
      for (int j = 0; j < primes.size(); j++) {
        if ((m & (1LL << j)) != 0) {
          res = res * (primes[j] - 1) % MOD;
          res = res * invPow[j] % MOD;
        }
      }
      cout << res << endLine;
    }
  }
  return 0;
}
