#include <bits/stdc++.h>
using namespace std;
const int max_n = 400000;
int m = 1000000000 + 7;
int val[4 * max_n];
unsigned long long pmask[4 * max_n];
unsigned long long updmask[4 * max_n];
int updval[4 * max_n];
vector<int> primes;
vector<int> reversed;
int mul(int a, int b) { return (int)(((unsigned long long)a * b) % m); }
int add(int a, int b) { return (int)(((unsigned long long)a + b) % m); }
int fpow(int a, int n, int res = 1) {
  while (n) {
    if (n % 2) {
      res = mul(res, a);
    }
    a = mul(a, a);
    n /= 2;
  }
  return res;
}
void make_tree(int id, int l, int r, vector<int> &a) {
  updval[id] = 1;
  if (l == r - 1) {
    val[id] = a[l];
    for (int i = 0; i < primes.size(); ++i) {
      if (a[l] % primes[i] == 0) {
        pmask[id] |= 1ULL << i;
      }
    }
  } else {
    int mid = (l + r) / 2;
    make_tree(2 * id + 1, l, mid, a);
    make_tree(2 * id + 2, mid, r, a);
    val[id] = mul(val[2 * id + 1], val[2 * id + 2]);
    pmask[id] = pmask[2 * id + 1] | pmask[2 * id + 2];
  }
}
void update(int id, int l, int r) {
  if (updval[id] != 1) {
    val[id] = fpow(updval[id], r - l, val[id]);
  }
  pmask[id] |= updmask[id];
  if (l != r - 1) {
    updval[2 * id + 1] = mul(updval[2 * id + 1], updval[id]);
    updval[2 * id + 2] = mul(updval[2 * id + 2], updval[id]);
    updmask[2 * id + 1] |= updmask[id];
    updmask[2 * id + 2] |= updmask[id];
  }
  updval[id] = 1;
  updmask[id] = 0;
}
pair<int, unsigned long long> get_val(int id, int l, int r, int constl,
                                      int constr) {
  if (r <= constl || l >= constr) {
    return pair<int, unsigned long long>(1, 0);
  }
  update(id, l, r);
  if (l >= constl && r <= constr) {
    return pair<int, unsigned long long>(val[id], pmask[id]);
  }
  int mid = (l + r) / 2;
  auto c1 = get_val(2 * id + 1, l, mid, constl, constr);
  auto c2 = get_val(2 * id + 2, mid, r, constl, constr);
  return pair<int, unsigned long long>(mul(c1.first, c2.first),
                                       c1.second | c2.second);
}
void multiply(int id, int l, int r, int constl, int constr, int x,
              unsigned long long msk) {
  if (l >= constr || r <= constl) {
    return;
  }
  update(id, l, r);
  if (l >= constl && r <= constr) {
    updval[id] = x;
    updmask[id] = msk;
    return;
  }
  int mid = (l + r) / 2;
  multiply(2 * id + 1, l, mid, constl, constr, x, msk);
  multiply(2 * id + 2, mid, r, constl, constr, x, msk);
  val[id] = fpow(x, min(r, constr) - max(l, constl), val[id]);
  pmask[id] |= msk;
}
int main() {
  for (int i = 2; i <= 300; ++i) {
    bool found = true;
    for (int j = 2; j * j <= i; ++j) {
      if (i % j == 0) {
        found = false;
        break;
      }
    }
    if (found) {
      primes.push_back(i);
      reversed.push_back(fpow(i, m - 2));
    }
  }
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  make_tree(0, 0, n, a);
  for (int i = 0; i < q; ++i) {
    string qu;
    cin >> qu;
    if (qu == "TOTIENT") {
      int l, r;
      cin >> l >> r;
      pair<int, unsigned long long> res = get_val(0, 0, n, l - 1, r);
      for (int j = 0; j < primes.size(); ++j) {
        if ((res.second >> j) & 1) {
          res.first = mul(mul(res.first, primes[j] - 1), reversed[j]);
        }
      }
      cout << res.first << endl;
    } else {
      int l, r, x;
      cin >> l >> r >> x;
      unsigned long long msk = 0;
      for (int j = 0; j < primes.size(); ++j) {
        if (x % primes[j] == 0) {
          msk |= 1ULL << j;
        }
      }
      multiply(0, 0, n, l - 1, r, x, msk);
    }
  }
  return 0;
}

### Prompt

Your task is to create 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;
const int max_n = 400000;
int m = 1000000000 + 7;
int val[4 * max_n];
unsigned long long pmask[4 * max_n];
unsigned long long updmask[4 * max_n];
int updval[4 * max_n];
vector<int> primes;
vector<int> reversed;
int mul(int a, int b) { return (int)(((unsigned long long)a * b) % m); }
int add(int a, int b) { return (int)(((unsigned long long)a + b) % m); }
int fpow(int a, int n, int res = 1) {
  while (n) {
    if (n % 2) {
      res = mul(res, a);
    }
    a = mul(a, a);
    n /= 2;
  }
  return res;
}
void make_tree(int id, int l, int r, vector<int> &a) {
  updval[id] = 1;
  if (l == r - 1) {
    val[id] = a[l];
    for (int i = 0; i < primes.size(); ++i) {
      if (a[l] % primes[i] == 0) {
        pmask[id] |= 1ULL << i;
      }
    }
  } else {
    int mid = (l + r) / 2;
    make_tree(2 * id + 1, l, mid, a);
    make_tree(2 * id + 2, mid, r, a);
    val[id] = mul(val[2 * id + 1], val[2 * id + 2]);
    pmask[id] = pmask[2 * id + 1] | pmask[2 * id + 2];
  }
}
void update(int id, int l, int r) {
  if (updval[id] != 1) {
    val[id] = fpow(updval[id], r - l, val[id]);
  }
  pmask[id] |= updmask[id];
  if (l != r - 1) {
    updval[2 * id + 1] = mul(updval[2 * id + 1], updval[id]);
    updval[2 * id + 2] = mul(updval[2 * id + 2], updval[id]);
    updmask[2 * id + 1] |= updmask[id];
    updmask[2 * id + 2] |= updmask[id];
  }
  updval[id] = 1;
  updmask[id] = 0;
}
pair<int, unsigned long long> get_val(int id, int l, int r, int constl,
                                      int constr) {
  if (r <= constl || l >= constr) {
    return pair<int, unsigned long long>(1, 0);
  }
  update(id, l, r);
  if (l >= constl && r <= constr) {
    return pair<int, unsigned long long>(val[id], pmask[id]);
  }
  int mid = (l + r) / 2;
  auto c1 = get_val(2 * id + 1, l, mid, constl, constr);
  auto c2 = get_val(2 * id + 2, mid, r, constl, constr);
  return pair<int, unsigned long long>(mul(c1.first, c2.first),
                                       c1.second | c2.second);
}
void multiply(int id, int l, int r, int constl, int constr, int x,
              unsigned long long msk) {
  if (l >= constr || r <= constl) {
    return;
  }
  update(id, l, r);
  if (l >= constl && r <= constr) {
    updval[id] = x;
    updmask[id] = msk;
    return;
  }
  int mid = (l + r) / 2;
  multiply(2 * id + 1, l, mid, constl, constr, x, msk);
  multiply(2 * id + 2, mid, r, constl, constr, x, msk);
  val[id] = fpow(x, min(r, constr) - max(l, constl), val[id]);
  pmask[id] |= msk;
}
int main() {
  for (int i = 2; i <= 300; ++i) {
    bool found = true;
    for (int j = 2; j * j <= i; ++j) {
      if (i % j == 0) {
        found = false;
        break;
      }
    }
    if (found) {
      primes.push_back(i);
      reversed.push_back(fpow(i, m - 2));
    }
  }
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  make_tree(0, 0, n, a);
  for (int i = 0; i < q; ++i) {
    string qu;
    cin >> qu;
    if (qu == "TOTIENT") {
      int l, r;
      cin >> l >> r;
      pair<int, unsigned long long> res = get_val(0, 0, n, l - 1, r);
      for (int j = 0; j < primes.size(); ++j) {
        if ((res.second >> j) & 1) {
          res.first = mul(mul(res.first, primes[j] - 1), reversed[j]);
        }
      }
      cout << res.first << endl;
    } else {
      int l, r, x;
      cin >> l >> r >> x;
      unsigned long long msk = 0;
      for (int j = 0; j < primes.size(); ++j) {
        if (x % primes[j] == 0) {
          msk |= 1ULL << j;
        }
      }
      multiply(0, 0, n, l - 1, r, x, msk);
    }
  }
  return 0;
}

```