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 long long MOD = 1000000007, INF = 1e9, LINF = 1e18;
const long double PI = acos(0), EPS = 1e-9, GOLD = ((1 + sqrt(5)) / 2);
struct Node {
  int val;
  int lazy;
};
struct Node1 {
  long long val;
  long long lazy;
};
int Prime[] = {2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,
               43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101,
               103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
               173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,
               241, 251, 257, 263, 269, 271, 277, 281, 283, 293};
vector<long long> Maskai(301, 0);
int poww(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 0) {
      a = (1LL * a * a) % MOD;
      b /= 2;
    } else {
      res = (1LL * res * a) % MOD;
      b -= 1;
    }
  }
  return res;
}
class multiai {
 private:
  vector<int> a;
  int id;
  vector<Node> ST;

 public:
  void Build(int l, int r, int node) {
    if (l == r) {
      ST[node].val = a[l];
      return;
    }
    Build(l, (l + r) / 2, node * 2);
    Build((l + r) / 2 + 1, r, node * 2 + 1);
    ST[node].val =
        ((ST[node * 2].val % MOD) * (ST[node * 2 + 1].val % MOD)) % MOD;
  }
  multiai(const vector<int> b) {
    a = b;
    id = a.size();
    ST.assign(4 * id, {1, 1});
    Build(0, id - 1, 1);
  }
  void updatelazy(int i, int j, int l, int r, int node, int x) {
    if (ST[node].lazy != 1) {
      ST[node].val = (((1LL * ST[node].val) % MOD) *
                      (poww(ST[node].lazy, r - l + 1)) % MOD) %
                     MOD;
      if (l != r) {
        ST[node * 2].lazy =
            ((ST[node * 2].lazy) % MOD * (ST[node].lazy) % MOD) % MOD;
        ST[node * 2 + 1].lazy =
            ((ST[node * 2 + 1].lazy) % MOD * (ST[node].lazy) % MOD) % MOD;
      }
      ST[node].lazy = 1;
    }
    if (i > r || j < l) return;
    if (l >= i && r <= j) {
      ST[node].lazy = (1LL * ST[node].lazy * x) % MOD;
      ST[node].val =
          ((1LL * ST[node].val) % MOD * poww(ST[node].lazy, r - l + 1) % MOD) %
          MOD;
      if (l != r) {
        ST[node * 2].lazy = ((ST[node * 2].lazy) % MOD * (x % MOD)) % MOD;
        ST[node * 2 + 1].lazy =
            ((ST[node * 2 + 1].lazy) % MOD * (x % MOD)) % MOD;
      }
      ST[node].lazy = 1;
      return;
    }
    updatelazy(i, j, (l + r) / 2 + 1, r, node * 2 + 1, x);
    updatelazy(i, j, l, (l + r) / 2, node * 2, x);
    ST[node].val =
        ((ST[node * 2].val % MOD) * (ST[node * 2 + 1].val % MOD)) % MOD;
  }
  int RMQ(int i, int j, int l, int r, int node) {
    if (i > r || j < l) return 1;
    if (ST[node].lazy != 1) {
      ST[node].val =
          ((1LL * ST[node].val) % MOD * poww(ST[node].lazy, r - l + 1) % MOD) %
          MOD;
      if (l != r) {
        ST[node * 2].lazy =
            ((ST[node * 2].lazy) % MOD * (ST[node].lazy) % MOD) % MOD;
        ST[node * 2 + 1].lazy =
            ((ST[node * 2 + 1].lazy) % MOD * (ST[node].lazy) % MOD) % MOD;
      }
      ST[node].lazy = 1;
    }
    if (i <= l && r <= j) {
      return ST[node].val;
    }
    int p1 = RMQ(i, j, (l + r) / 2 + 1, r, node * 2 + 1);
    int p2 = RMQ(i, j, l, (l + r) / 2, node * 2);
    return ((p1 % MOD) * (p2 % MOD)) % MOD;
  }
  int RMQ(int i, int j) { return RMQ(i, j, 0, id - 1, 1); }
};
class MultiPrime {
 private:
  int id;
  vector<long long> a;
  vector<Node1> ST;

 public:
  void Build(int l, int r, int node) {
    if (l == r) {
      ST[node].val = a[l];
      return;
    }
    Build((l + r) / 2 + 1, r, node * 2 + 1);
    Build(l, (l + r) / 2, node * 2);
    ST[node].val = ST[node * 2 + 1].val | ST[node * 2].val;
  }
  MultiPrime(const vector<long long> b) {
    a = b;
    id = a.size();
    ST.assign(4 * id, {0, 0});
    Build(0, id - 1, 1);
  }
  void updatelazy(int i, int j, int l, int r, int node, long long x) {
    if (ST[node].lazy != 0) {
      ST[node].val = (ST[node].val) | (ST[node].lazy);
      if (l != r) {
        ST[node * 2].lazy |= ST[node].lazy;
        ST[node * 2 + 1].lazy |= ST[node].lazy;
      }
      ST[node].lazy = 0;
    }
    if (i > r || j < l) return;
    if (i <= l && r <= j) {
      ST[node].val |= x;
      if (l != r) {
        ST[node * 2].lazy |= x;
        ST[node * 2 + 1].lazy |= x;
      }
      return;
    }
    updatelazy(i, j, l, (l + r) / 2, node * 2, x);
    updatelazy(i, j, (l + r) / 2 + 1, r, node * 2 + 1, x);
    ST[node].val = (ST[node * 2].val | ST[node * 2 + 1].val);
  }
  long long RMQ(int i, int j, int l, int r, int node) {
    if (i > r || j < l) return 0;
    if (ST[node].lazy != 0) {
      ST[node].val |= ST[node].lazy;
      if (l != r) {
        ST[node * 2].lazy |= ST[node].lazy;
        ST[node * 2 + 1].lazy |= ST[node].lazy;
      }
      ST[node].lazy = 0;
    }
    if (i <= l && r <= j) {
      return ST[node].val;
    }
    long long p1 = RMQ(i, j, (l + r) / 2 + 1, r, node * 2 + 1);
    long long p2 = RMQ(i, j, l, (l + r) / 2, node * 2);
    return (p1 | p2);
  }
  long long RMQ(int i, int j) { return RMQ(i, j, 0, id - 1, 1); }
};
int main() {
  for (int i = 1; i <= 300; i++) {
    for (int j = 0; j < 62; j++) {
      if (i % Prime[j] != 0) continue;
      Maskai[i] = Maskai[i] | (1LL << j);
    }
  }
  vector<int> inPrime(62, 0);
  for (int i = 0; i < 62; i++) inPrime[i] = poww(Prime[i], MOD - 2);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  vector<long long> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = Maskai[a[i]];
  }
  multiai tre1(a);
  MultiPrime tre2(b);
  while (q--) {
    string s;
    cin >> s;
    if (s == "MULTIPLY") {
      int l, r, x;
      cin >> l >> r >> x;
      l--;
      r--;
      tre1.updatelazy(l, r, 0, n - 1, 1, x);
      tre2.updatelazy(l, r, 0, n - 1, 1, Maskai[x]);
    } else {
      int l, r;
      cin >> l >> r;
      l--;
      r--;
      int mul1 = tre1.RMQ(l, r);
      long long masss = tre2.RMQ(l, r);
      for (int i = 0; i < 62; i++) {
        if ((masss & (1LL << i)) == 0) continue;
        mul1 = (1LL * mul1 * (Prime[i] - 1)) % MOD;
        mul1 = (1LL * mul1 * inPrime[i]) % MOD;
      }
      cout << mul1 << endl;
    }
  }
}
