#include <bits/stdc++.h>
using std::abs;
using std::array;
using std::cerr;
using std::cin;
using std::cout;
using std::generate;
using std::get;
using std::make_pair;
using std::make_tuple;
using std::map;
using std::max;
using std::max_element;
using std::min;
using std::min_element;
using std::pair;
using std::reverse;
using std::set;
using std::sort;
using std::string;
using std::swap;
using std::tuple;
using std::unique;
using std::vector;
template <typename T>
T input() {
  T res;
  cin >> res;
  {};
  return res;
}
template <typename IT>
void input_seq(IT b, IT e) {
  std::generate(b, e,
                input<typename std::remove_reference<decltype(*b)>::type>);
}
const int mod = 1000 * 1000 * 1000 + 7;
int add(int a, int b) { return (a + b >= mod ? a + b - mod : a + b); }
int sub(int a, int b) { return (a >= b ? a - b : mod + a - b); }
int mult(int a, int b) { return (int64_t(a) * b) % mod; }
int fpow(int a, int n, int r = 1) {
  while (n) {
    if (n % 2) r = mult(r, a);
    n /= 2;
    a = mult(a, a);
  }
  return r;
}
const int max_n = 4.1e5;
int tree[4 * max_n];
int modif[4 * max_n];
int64_t pmask[4 * max_n], pushmask[4 * max_n];
vector<int> primes, revprimes;
void build(int v, int l, int r, vector<int>& a) {
  modif[v] = 1;
  if (l == r - 1) {
    tree[v] = a[l];
    for (int i = 0; i != int((primes).size()); ++i)
      if (a[l] % primes[i] == 0) pmask[v] |= (int64_t(1) << int64_t(i));
  } else {
    int m = l + (r - l) / 2;
    build(2 * v + 1, l, m, a);
    build(2 * v + 2, m, r, a);
    tree[v] = mult(tree[2 * v + 1], tree[2 * v + 2]);
    pmask[v] = pmask[2 * v + 1] | pmask[2 * v + 2];
  }
}
void push(int v, int vl, int vr) {
  if (modif[v] != 1) tree[v] = fpow(modif[v], vr - vl, tree[v]);
  pmask[v] |= pushmask[v];
  if (vl != vr - 1) {
    modif[2 * v + 1] = mult(modif[2 * v + 1], modif[v]);
    modif[2 * v + 2] = mult(modif[2 * v + 2], modif[v]);
    pushmask[2 * v + 1] |= pushmask[v];
    pushmask[2 * v + 2] |= pushmask[v];
  }
  modif[v] = 1;
  pushmask[v] = 0;
}
pair<int, int64_t> get(int v, int vl, int vr, int l, int r) {
  if (vr <= l or r <= vl) return make_pair<int, int64_t>(1, 0);
  push(v, vl, vr);
  if (l <= vl and vr <= r) return make_pair(tree[v], pmask[v]);
  int vm = vl + (vr - vl) / 2;
  auto r1 = get(2 * v + 1, vl, vm, l, r);
  auto r2 = get(2 * v + 2, vm, vr, l, r);
  return make_pair(mult(r1.first, r2.first), r1.second | r2.second);
}
void multiply(int v, int vl, int vr, int l, int r, int x, int64_t mask) {
  if (vr <= l or r <= vl) return;
  push(v, vl, vr);
  if (l <= vl and vr <= r) {
    pushmask[v] = mask;
    modif[v] = x;
    return;
  }
  int vm = vl + (vr - vl) / 2;
  multiply(2 * v + 1, vl, vm, l, r, x, mask);
  multiply(2 * v + 2, vm, vr, l, r, x, mask);
  pmask[v] = pmask[2 * v + 1] | pmask[2 * v + 2] | pushmask[2 * v + 1] |
             pushmask[2 * v + 2];
  tree[v] = fpow(x, min(vr, r) - max(l, vl), tree[v]);
}
int main() {
  std::iostream::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  for (int i = 2; i <= 300; ++i) {
    bool ok = true;
    for (int j = 2; j * j <= i and ok; ++j)
      if (i % j == 0) ok = false;
    if (ok) {
      primes.push_back(i);
      revprimes.push_back(fpow(i, mod - 2));
    }
  }
  int n = input<int>();
  int q = input<int>();
  vector<int> a(n);
  input_seq(a.begin(), a.end());
  build(0, 0, n, a);
  for (int it = 0; it != q; ++it) {
    if (input<string>() == "TOTIENT") {
      int l = input<int>() - 1;
      int r = input<int>() - 1;
      pair<int, uint64_t> prod = get(0, 0, n, l, r + 1);
      for (int i = 0; i != int((primes).size()); ++i)
        if (prod.second & (int64_t(1) << int64_t(i)))
          prod.first = mult(mult(prod.first, primes[i] - 1), revprimes[i]);
      cout << prod.first << "\n";
    } else {
      int l = input<int>() - 1;
      int r = input<int>() - 1;
      int x = input<int>();
      int64_t msk = 0;
      for (int i = 0; i != int((primes).size()); ++i)
        if (x % primes[i] == 0) msk |= (int64_t(1) << int64_t(i));
      multiply(0, 0, n, l, r + 1, x, msk);
    }
  }
  return 0;
}

### Prompt

Develop a solution in CPP to the problem described below:

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 std::abs;
using std::array;
using std::cerr;
using std::cin;
using std::cout;
using std::generate;
using std::get;
using std::make_pair;
using std::make_tuple;
using std::map;
using std::max;
using std::max_element;
using std::min;
using std::min_element;
using std::pair;
using std::reverse;
using std::set;
using std::sort;
using std::string;
using std::swap;
using std::tuple;
using std::unique;
using std::vector;
template <typename T>
T input() {
  T res;
  cin >> res;
  {};
  return res;
}
template <typename IT>
void input_seq(IT b, IT e) {
  std::generate(b, e,
                input<typename std::remove_reference<decltype(*b)>::type>);
}
const int mod = 1000 * 1000 * 1000 + 7;
int add(int a, int b) { return (a + b >= mod ? a + b - mod : a + b); }
int sub(int a, int b) { return (a >= b ? a - b : mod + a - b); }
int mult(int a, int b) { return (int64_t(a) * b) % mod; }
int fpow(int a, int n, int r = 1) {
  while (n) {
    if (n % 2) r = mult(r, a);
    n /= 2;
    a = mult(a, a);
  }
  return r;
}
const int max_n = 4.1e5;
int tree[4 * max_n];
int modif[4 * max_n];
int64_t pmask[4 * max_n], pushmask[4 * max_n];
vector<int> primes, revprimes;
void build(int v, int l, int r, vector<int>& a) {
  modif[v] = 1;
  if (l == r - 1) {
    tree[v] = a[l];
    for (int i = 0; i != int((primes).size()); ++i)
      if (a[l] % primes[i] == 0) pmask[v] |= (int64_t(1) << int64_t(i));
  } else {
    int m = l + (r - l) / 2;
    build(2 * v + 1, l, m, a);
    build(2 * v + 2, m, r, a);
    tree[v] = mult(tree[2 * v + 1], tree[2 * v + 2]);
    pmask[v] = pmask[2 * v + 1] | pmask[2 * v + 2];
  }
}
void push(int v, int vl, int vr) {
  if (modif[v] != 1) tree[v] = fpow(modif[v], vr - vl, tree[v]);
  pmask[v] |= pushmask[v];
  if (vl != vr - 1) {
    modif[2 * v + 1] = mult(modif[2 * v + 1], modif[v]);
    modif[2 * v + 2] = mult(modif[2 * v + 2], modif[v]);
    pushmask[2 * v + 1] |= pushmask[v];
    pushmask[2 * v + 2] |= pushmask[v];
  }
  modif[v] = 1;
  pushmask[v] = 0;
}
pair<int, int64_t> get(int v, int vl, int vr, int l, int r) {
  if (vr <= l or r <= vl) return make_pair<int, int64_t>(1, 0);
  push(v, vl, vr);
  if (l <= vl and vr <= r) return make_pair(tree[v], pmask[v]);
  int vm = vl + (vr - vl) / 2;
  auto r1 = get(2 * v + 1, vl, vm, l, r);
  auto r2 = get(2 * v + 2, vm, vr, l, r);
  return make_pair(mult(r1.first, r2.first), r1.second | r2.second);
}
void multiply(int v, int vl, int vr, int l, int r, int x, int64_t mask) {
  if (vr <= l or r <= vl) return;
  push(v, vl, vr);
  if (l <= vl and vr <= r) {
    pushmask[v] = mask;
    modif[v] = x;
    return;
  }
  int vm = vl + (vr - vl) / 2;
  multiply(2 * v + 1, vl, vm, l, r, x, mask);
  multiply(2 * v + 2, vm, vr, l, r, x, mask);
  pmask[v] = pmask[2 * v + 1] | pmask[2 * v + 2] | pushmask[2 * v + 1] |
             pushmask[2 * v + 2];
  tree[v] = fpow(x, min(vr, r) - max(l, vl), tree[v]);
}
int main() {
  std::iostream::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  for (int i = 2; i <= 300; ++i) {
    bool ok = true;
    for (int j = 2; j * j <= i and ok; ++j)
      if (i % j == 0) ok = false;
    if (ok) {
      primes.push_back(i);
      revprimes.push_back(fpow(i, mod - 2));
    }
  }
  int n = input<int>();
  int q = input<int>();
  vector<int> a(n);
  input_seq(a.begin(), a.end());
  build(0, 0, n, a);
  for (int it = 0; it != q; ++it) {
    if (input<string>() == "TOTIENT") {
      int l = input<int>() - 1;
      int r = input<int>() - 1;
      pair<int, uint64_t> prod = get(0, 0, n, l, r + 1);
      for (int i = 0; i != int((primes).size()); ++i)
        if (prod.second & (int64_t(1) << int64_t(i)))
          prod.first = mult(mult(prod.first, primes[i] - 1), revprimes[i]);
      cout << prod.first << "\n";
    } else {
      int l = input<int>() - 1;
      int r = input<int>() - 1;
      int x = input<int>();
      int64_t msk = 0;
      for (int i = 0; i != int((primes).size()); ++i)
        if (x % primes[i] == 0) msk |= (int64_t(1) << int64_t(i));
      multiply(0, 0, n, l, r + 1, x, msk);
    }
  }
  return 0;
}

```