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;
using ll = long long;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (T e : v) {
    os << e << ' ';
  }
  return os;
}
constexpr ll mod = 1e9 + 7;
constexpr int kMaxS = 2e6;
int s;
ll primes[kMaxS];
ll prods[kMaxS];
bool lazy[kMaxS];
ll primeupdate[kMaxS];
ll produpdate[kMaxS];
ll prime[301];
vector<ll> pf, calculated;
ll powmod(ll a, ll b) {
  if (b == 0) {
    return 1LL;
  }
  if (b % 2 == 0) {
    ll tmp = powmod(a, b / 2);
    return tmp * tmp % mod;
  }
  return a * powmod(a, b - 1) % mod;
}
void update(int idx, int L, int R) {
  if (!lazy[idx]) {
    return;
  }
  primes[idx] |= primeupdate[idx];
  prods[idx] = prods[idx] * powmod(produpdate[idx], R - L + 1) % mod;
  int l = 2 * idx, r = l + 1;
  if (r < 2 * s) {
    lazy[l] = lazy[r] = true;
    produpdate[l] = produpdate[l] * produpdate[idx] % mod;
    produpdate[r] = produpdate[r] * produpdate[idx] % mod;
    primeupdate[l] |= primeupdate[idx];
    primeupdate[r] |= primeupdate[idx];
  }
  lazy[idx] = false;
  produpdate[idx] = 1;
  primeupdate[idx] = 0;
}
void update(int l, int r, int x, int idx, int L, int R) {
  if (l == L && r == R) {
    lazy[idx] = true;
    produpdate[idx] = produpdate[idx] * x % mod;
    primeupdate[idx] |= prime[x];
    return;
  }
  prods[idx] = prods[idx] * powmod(x, r - l + 1) % mod;
  primes[idx] |= prime[x];
  int M = (L + R) / 2;
  if (r <= M) {
    update(l, r, x, 2 * idx, L, M);
  } else if (l > M) {
    update(l, r, x, 2 * idx + 1, M + 1, R);
  } else {
    update(l, M, x, 2 * idx, L, M);
    update(M + 1, r, x, 2 * idx + 1, M + 1, R);
  }
}
pair<ll, ll> get(int l, int r, int idx, int L, int R) {
  update(idx, L, R);
  if (l == L && r == R) {
    return {prods[idx], primes[idx]};
  }
  int M = (L + R) / 2;
  if (r <= M) {
    return get(l, r, 2 * idx, L, M);
  } else if (l > M) {
    return get(l, r, 2 * idx + 1, M + 1, R);
  } else {
    auto left = get(l, M, 2 * idx, L, M);
    auto right = get(M + 1, r, 2 * idx + 1, M + 1, R);
    return {left.first * right.first % mod, left.second | right.second};
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  {
    auto is_prime = [](int num) {
      if (num % 2 == 0) {
        return num == 2;
      }
      for (int j = 3; j * j <= num; j += 2) {
        if (num % j == 0) {
          return false;
        }
      }
      return true;
    };
    for (int i = 2; i <= 300; ++i) {
      if (is_prime(i)) {
        pf.emplace_back(i);
      }
    }
    for (int i = 2; i <= 300; ++i) {
      ll cur = 0;
      for (int j = 0; j < pf.size() && pf[j] <= i; ++j) {
        if (i % pf[j] == 0) {
          cur |= 1LL << j;
        }
      }
      prime[i] = cur;
    }
    calculated.resize(pf.size());
    for (int i = 0; i < pf.size(); ++i) {
      ll inv = powmod(pf[i], mod - 2);
      calculated[i] = (pf[i] - 1LL) * inv % mod;
    }
  }
  int n, q;
  cin >> n >> q;
  s = 1;
  while (s < n) {
    s *= 2;
  }
  auto print_arr = [&] {
    cout << "Prods\n";
    for (int i = 0; i < n; ++i) {
      (void)get(i + 1, i + 1, 1, 1, s);
      cout << dec << prods[s + i] << ' ';
    }
    cout << '\n';
  };
  function<void(int, int, int)> print_prods = [&](int idx, int l, int r) {
    update(idx, l, r);
    cout << dec << "(" << l << "," << r << "): " << prods[idx] << '\n';
    if (idx < s) {
      int m = (l + r) / 2;
      print_prods(2 * idx, l, m);
      print_prods(2 * idx + 1, m + 1, r);
    }
  };
  assert(2 * s < 2e6);
  for (int i = 0; i < 2 * s; ++i) {
    prods[i] = 1;
    produpdate[i] = 1;
  }
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    prods[s + i] = a;
    primes[s + i] = prime[a];
  }
  for (int j = s - 1; j > 0; --j) {
    int l = 2 * j, r = l + 1;
    prods[j] = prods[l] * prods[r] % mod;
    primes[j] = primes[l] | primes[r];
  }
  while (q--) {
    string cmd;
    cin >> cmd;
    int l, r;
    cin >> l >> r;
    if (cmd == "MULTIPLY") {
      int x;
      cin >> x;
      update(l, r, x, 1, 1, s);
    } else if (cmd == "TOTIENT") {
      auto tmp = get(l, r, 1, 1, s);
      ll prod = tmp.first, p = tmp.second;
      int i = 0;
      while (p) {
        if (p & 1) {
          prod = prod * calculated[i] % mod;
        }
        ++i;
        p /= 2;
      }
      cout << prod << '\n';
    } else {
      cerr << "Invalid command\n";
      exit(1);
    }
  }
  return 0;
}
