#include <bits/stdc++.h>
using namespace std;
int n, q;
int a[400001];
struct node {
  long long ans;
  long long p;
} tree[4 * 400001], lazy[4 * 400001], dp[301];
vector<int> prime;
long long power(int x, int n) {
  if (n == 0) return 1;
  if (n & 1) {
    return (x * power(x, n - 1)) % 1000000007;
  }
  long long y = power(x, n / 2);
  return (y * y) % 1000000007;
}
long long d, x, y;
void extendedEuclid(long long A, long long B) {
  if (B == 0) {
    d = A;
    x = 1;
    y = 0;
  } else {
    extendedEuclid(B, A % B);
    long long temp = x;
    x = y;
    y = temp - (A / B) * y;
  }
}
long long modInverse(long long A, long long M) {
  extendedEuclid(A, M);
  return (x % M + M) % M;
}
void help(int n, int i) {
  long long p = 0;
  for (long long i = 0; i < prime.size(); i++) {
    if (n % prime[i] == 0) p = p | (1ll << i);
  }
  dp[i].ans = n;
  dp[i].p = p;
}
void combine(struct node &n, struct node &left, struct node &right) {
  n.ans = (left.ans * right.ans) % 1000000007;
  n.p = left.p | right.p;
}
void build(int node, int start, int end) {
  if (start == end) {
    tree[node] = dp[a[start]];
  } else {
    int mid = (start + end) / 2;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    combine(tree[node], tree[2 * node], tree[2 * node + 1]);
  }
}
void updateRange(int node, int start, int end, int l, int r, int val) {
  if (lazy[node].p != 0) {
    long long temp = power(lazy[node].ans, end - start + 1);
    tree[node].ans = (tree[node].ans * temp) % 1000000007;
    tree[node].p = tree[node].p | lazy[node].p;
    if (start != end) {
      lazy[node * 2].ans = (lazy[node * 2].ans * lazy[node].ans) % 1000000007;
      lazy[node * 2 + 1].ans =
          (lazy[node * 2 + 1].ans * lazy[node].ans) % 1000000007;
      lazy[node * 2].p = lazy[node * 2].p | lazy[node].p;
      lazy[node * 2 + 1].p = lazy[node * 2 + 1].p | lazy[node].p;
    }
    lazy[node].ans = 1;
    lazy[node].p = 0;
  }
  if (start > end or start > r or end < l) return;
  if (start >= l and end <= r) {
    long long temp = power(dp[val].ans, end - start + 1);
    tree[node].ans = (tree[node].ans * temp) % 1000000007;
    tree[node].p = tree[node].p | dp[val].p;
    if (start != end) {
      lazy[node * 2].ans = (lazy[node * 2].ans * dp[val].ans) % 1000000007;
      lazy[node * 2 + 1].ans =
          (lazy[node * 2 + 1].ans * dp[val].ans) % 1000000007;
      lazy[node * 2].p = lazy[node * 2].p | dp[val].p;
      lazy[node * 2 + 1].p = lazy[node * 2 + 1].p | dp[val].p;
    }
    return;
  }
  int mid = (start + end) / 2;
  updateRange(node * 2, start, mid, l, r, val);
  updateRange(node * 2 + 1, mid + 1, end, l, r, val);
  combine(tree[node], tree[node * 2], tree[node * 2 + 1]);
}
struct node queryRange(int node, int start, int end, int l, int r) {
  if (start > end or start > r or end < l) {
    struct node temp;
    temp.ans = 1;
    temp.p = 0;
    return temp;
  }
  if (lazy[node].p != 0) {
    long long temp = power(lazy[node].ans, end - start + 1);
    tree[node].ans = (tree[node].ans * temp) % 1000000007;
    tree[node].p = tree[node].p | lazy[node].p;
    if (start != end) {
      lazy[node * 2].ans = (lazy[node * 2].ans * lazy[node].ans) % 1000000007;
      lazy[node * 2 + 1].ans =
          (lazy[node * 2 + 1].ans * lazy[node].ans) % 1000000007;
      lazy[node * 2].p = lazy[node * 2].p | lazy[node].p;
      lazy[node * 2 + 1].p = lazy[node * 2 + 1].p | lazy[node].p;
    }
    lazy[node].ans = 1;
    lazy[node].p = 0;
  }
  if (start >= l and end <= r) return tree[node];
  int mid = (start + end) / 2;
  struct node temp;
  struct node p1 = queryRange(node * 2, start, mid, l, r);
  struct node p2 = queryRange(node * 2 + 1, mid + 1, end, l, r);
  combine(temp, p1, p2);
  return temp;
}
long long func(struct node &n) {
  long long ans = n.ans;
  for (long long i = 0; i < prime.size(); i++) {
    if (n.p & (1ll << i)) {
      long long temp =
          ((prime[i] - 1) * modInverse(prime[i], 1000000007)) % 1000000007;
      ans = (ans * temp) % 1000000007;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 2; i <= 300; i++) {
    bool isPrime = true;
    for (int j = 2; j <= sqrt(i); j++) {
      if (i % j == 0) {
        isPrime = false;
        break;
      }
    }
    if (isPrime) prime.push_back(i);
  }
  for (int i = 1; i <= 300; i++) help(i, i);
  for (int i = 0; i < 4 * 400001; i++) {
    tree[i].ans = 1;
    tree[i].p = 0;
    lazy[i].ans = 1;
    lazy[i].p = 0;
  }
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  build(1, 1, n);
  while (q--) {
    string s;
    int l, r, x;
    cin >> s;
    if (s[0] == 'M') {
      cin >> l >> r >> x;
      updateRange(1, 1, n, l, r, x);
    } else {
      cin >> l >> r;
      struct node temp = queryRange(1, 1, n, l, r);
      cout << func(temp) << "\n";
    }
  }
  return 0;
}

### Prompt

Your challenge is to write a CPP solution to 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;
int n, q;
int a[400001];
struct node {
  long long ans;
  long long p;
} tree[4 * 400001], lazy[4 * 400001], dp[301];
vector<int> prime;
long long power(int x, int n) {
  if (n == 0) return 1;
  if (n & 1) {
    return (x * power(x, n - 1)) % 1000000007;
  }
  long long y = power(x, n / 2);
  return (y * y) % 1000000007;
}
long long d, x, y;
void extendedEuclid(long long A, long long B) {
  if (B == 0) {
    d = A;
    x = 1;
    y = 0;
  } else {
    extendedEuclid(B, A % B);
    long long temp = x;
    x = y;
    y = temp - (A / B) * y;
  }
}
long long modInverse(long long A, long long M) {
  extendedEuclid(A, M);
  return (x % M + M) % M;
}
void help(int n, int i) {
  long long p = 0;
  for (long long i = 0; i < prime.size(); i++) {
    if (n % prime[i] == 0) p = p | (1ll << i);
  }
  dp[i].ans = n;
  dp[i].p = p;
}
void combine(struct node &n, struct node &left, struct node &right) {
  n.ans = (left.ans * right.ans) % 1000000007;
  n.p = left.p | right.p;
}
void build(int node, int start, int end) {
  if (start == end) {
    tree[node] = dp[a[start]];
  } else {
    int mid = (start + end) / 2;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    combine(tree[node], tree[2 * node], tree[2 * node + 1]);
  }
}
void updateRange(int node, int start, int end, int l, int r, int val) {
  if (lazy[node].p != 0) {
    long long temp = power(lazy[node].ans, end - start + 1);
    tree[node].ans = (tree[node].ans * temp) % 1000000007;
    tree[node].p = tree[node].p | lazy[node].p;
    if (start != end) {
      lazy[node * 2].ans = (lazy[node * 2].ans * lazy[node].ans) % 1000000007;
      lazy[node * 2 + 1].ans =
          (lazy[node * 2 + 1].ans * lazy[node].ans) % 1000000007;
      lazy[node * 2].p = lazy[node * 2].p | lazy[node].p;
      lazy[node * 2 + 1].p = lazy[node * 2 + 1].p | lazy[node].p;
    }
    lazy[node].ans = 1;
    lazy[node].p = 0;
  }
  if (start > end or start > r or end < l) return;
  if (start >= l and end <= r) {
    long long temp = power(dp[val].ans, end - start + 1);
    tree[node].ans = (tree[node].ans * temp) % 1000000007;
    tree[node].p = tree[node].p | dp[val].p;
    if (start != end) {
      lazy[node * 2].ans = (lazy[node * 2].ans * dp[val].ans) % 1000000007;
      lazy[node * 2 + 1].ans =
          (lazy[node * 2 + 1].ans * dp[val].ans) % 1000000007;
      lazy[node * 2].p = lazy[node * 2].p | dp[val].p;
      lazy[node * 2 + 1].p = lazy[node * 2 + 1].p | dp[val].p;
    }
    return;
  }
  int mid = (start + end) / 2;
  updateRange(node * 2, start, mid, l, r, val);
  updateRange(node * 2 + 1, mid + 1, end, l, r, val);
  combine(tree[node], tree[node * 2], tree[node * 2 + 1]);
}
struct node queryRange(int node, int start, int end, int l, int r) {
  if (start > end or start > r or end < l) {
    struct node temp;
    temp.ans = 1;
    temp.p = 0;
    return temp;
  }
  if (lazy[node].p != 0) {
    long long temp = power(lazy[node].ans, end - start + 1);
    tree[node].ans = (tree[node].ans * temp) % 1000000007;
    tree[node].p = tree[node].p | lazy[node].p;
    if (start != end) {
      lazy[node * 2].ans = (lazy[node * 2].ans * lazy[node].ans) % 1000000007;
      lazy[node * 2 + 1].ans =
          (lazy[node * 2 + 1].ans * lazy[node].ans) % 1000000007;
      lazy[node * 2].p = lazy[node * 2].p | lazy[node].p;
      lazy[node * 2 + 1].p = lazy[node * 2 + 1].p | lazy[node].p;
    }
    lazy[node].ans = 1;
    lazy[node].p = 0;
  }
  if (start >= l and end <= r) return tree[node];
  int mid = (start + end) / 2;
  struct node temp;
  struct node p1 = queryRange(node * 2, start, mid, l, r);
  struct node p2 = queryRange(node * 2 + 1, mid + 1, end, l, r);
  combine(temp, p1, p2);
  return temp;
}
long long func(struct node &n) {
  long long ans = n.ans;
  for (long long i = 0; i < prime.size(); i++) {
    if (n.p & (1ll << i)) {
      long long temp =
          ((prime[i] - 1) * modInverse(prime[i], 1000000007)) % 1000000007;
      ans = (ans * temp) % 1000000007;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 2; i <= 300; i++) {
    bool isPrime = true;
    for (int j = 2; j <= sqrt(i); j++) {
      if (i % j == 0) {
        isPrime = false;
        break;
      }
    }
    if (isPrime) prime.push_back(i);
  }
  for (int i = 1; i <= 300; i++) help(i, i);
  for (int i = 0; i < 4 * 400001; i++) {
    tree[i].ans = 1;
    tree[i].p = 0;
    lazy[i].ans = 1;
    lazy[i].p = 0;
  }
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  build(1, 1, n);
  while (q--) {
    string s;
    int l, r, x;
    cin >> s;
    if (s[0] == 'M') {
      cin >> l >> r >> x;
      updateRange(1, 1, n, l, r, x);
    } else {
      cin >> l >> r;
      struct node temp = queryRange(1, 1, n, l, r);
      cout << func(temp) << "\n";
    }
  }
  return 0;
}

```