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 maxn = 2e6 + 5;
const long long inf = 0x3f3f3f3f;
const long long iinf = 1 << 30;
const long long linf = 2e18;
const long long mod = 1e9 + 7;
const double eps = 1e-7;
void douout(double x) { printf("%lf\n", x + 0.0000000001); }
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void add(T &a, T b) {
  a = (1ll * a + b) % mod;
}
template <class T>
void sub(T &a, T b) {
  a = (a - b + mod) % mod;
}
template <class T>
void mul(T &a, T b) {
  a = (long long)a * b % mod;
}
template <class T>
void read(T &a) {
  long long f = 1;
  a = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    a = (a << 3) + (a << 1) + ch - '0';
    ch = getchar();
  }
  a *= f;
}
long long bit[305], prime[70], inv[70];
void init() {
  prime[1] = 2, prime[2] = 3, prime[3] = 5, prime[4] = 7, prime[5] = 11,
  prime[6] = 13, prime[7] = 17, prime[8] = 19, prime[9] = 23, prime[10] = 29,
  prime[11] = 31, prime[12] = 37, prime[13] = 41, prime[14] = 43,
  prime[15] = 47, prime[16] = 53, prime[17] = 59, prime[18] = 61,
  prime[19] = 67, prime[20] = 71, prime[21] = 73, prime[22] = 79,
  prime[23] = 83, prime[24] = 89, prime[25] = 97, prime[26] = 101,
  prime[27] = 103, prime[28] = 107, prime[29] = 109, prime[30] = 113,
  prime[31] = 127, prime[32] = 131, prime[33] = 137, prime[34] = 139,
  prime[35] = 149, prime[36] = 151, prime[37] = 157, prime[38] = 163,
  prime[39] = 167, prime[40] = 173, prime[41] = 179, prime[42] = 181,
  prime[43] = 191, prime[44] = 193, prime[45] = 197, prime[46] = 199,
  prime[47] = 211, prime[48] = 223, prime[49] = 227, prime[50] = 229,
  prime[51] = 233, prime[52] = 239, prime[53] = 241, prime[54] = 251,
  prime[55] = 257, prime[56] = 263, prime[57] = 269, prime[58] = 271,
  prime[59] = 277, prime[60] = 281, prime[61] = 283, prime[62] = 293;
  inv[1] = 500000004, inv[2] = 333333336, inv[3] = 400000003,
  inv[4] = 142857144, inv[5] = 818181824, inv[6] = 153846155,
  inv[7] = 352941179, inv[8] = 157894738, inv[9] = 739130440,
  inv[10] = 758620695, inv[11] = 129032259, inv[12] = 621621626,
  inv[13] = 658536590, inv[14] = 395348840, inv[15] = 404255322,
  inv[16] = 56603774, inv[17] = 50847458, inv[18] = 688524595,
  inv[19] = 686567169, inv[20] = 98591550, inv[21] = 410958907,
  inv[22] = 202531647, inv[23] = 84337350, inv[24] = 415730340,
  inv[25] = 268041239, inv[26] = 940594066, inv[27] = 572815538,
  inv[28] = 224299067, inv[29] = 9174312, inv[30] = 893805316,
  inv[31] = 480314964, inv[32] = 190839696, inv[33] = 58394161,
  inv[34] = 604316551, inv[35] = 530201346, inv[36] = 483443712,
  inv[37] = 343949047, inv[38] = 116564418, inv[39] = 5988024,
  inv[40] = 791907520, inv[41] = 435754193, inv[42] = 933701664,
  inv[43] = 439790579, inv[44] = 694300523, inv[45] = 969543154,
  inv[46] = 507537692, inv[47] = 90047394, inv[48] = 125560539,
  inv[49] = 35242291, inv[50] = 711790398, inv[51] = 90128756,
  inv[52] = 280334730, inv[53] = 406639007, inv[54] = 912350604,
  inv[55] = 70038911, inv[56] = 836501907, inv[57] = 743494429,
  inv[58] = 450184505, inv[59] = 252707583, inv[60] = 718861215,
  inv[61] = 650176683, inv[62] = 522184304;
  bit[2] = 2, bit[3] = 4, bit[4] = 2, bit[5] = 8, bit[6] = 6, bit[7] = 16,
  bit[8] = 2, bit[9] = 4, bit[10] = 10, bit[11] = 32, bit[12] = 6, bit[13] = 64,
  bit[14] = 18, bit[15] = 12, bit[16] = 2, bit[17] = 128, bit[18] = 6,
  bit[19] = 256, bit[20] = 10, bit[21] = 20, bit[22] = 34, bit[23] = 512,
  bit[24] = 6, bit[25] = 8, bit[26] = 66, bit[27] = 4, bit[28] = 18,
  bit[29] = 1024, bit[30] = 14, bit[31] = 2048, bit[32] = 2, bit[33] = 36,
  bit[34] = 130, bit[35] = 24, bit[36] = 6, bit[37] = 4096, bit[38] = 258,
  bit[39] = 68, bit[40] = 10, bit[41] = 8192, bit[42] = 22, bit[43] = 16384,
  bit[44] = 34, bit[45] = 12, bit[46] = 514, bit[47] = 32768, bit[48] = 6,
  bit[49] = 16, bit[50] = 10, bit[51] = 132, bit[52] = 66, bit[53] = 65536,
  bit[54] = 6, bit[55] = 40, bit[56] = 18, bit[57] = 260, bit[58] = 1026,
  bit[59] = 131072, bit[60] = 14, bit[61] = 262144, bit[62] = 2050,
  bit[63] = 20, bit[64] = 2, bit[65] = 72, bit[66] = 38, bit[67] = 524288,
  bit[68] = 130, bit[69] = 516, bit[70] = 26, bit[71] = 1048576, bit[72] = 6,
  bit[73] = 2097152, bit[74] = 4098, bit[75] = 12, bit[76] = 258, bit[77] = 48,
  bit[78] = 70, bit[79] = 4194304, bit[80] = 10, bit[81] = 4, bit[82] = 8194,
  bit[83] = 8388608, bit[84] = 22, bit[85] = 136, bit[86] = 16386,
  bit[87] = 1028, bit[88] = 34, bit[89] = 16777216, bit[90] = 14, bit[91] = 80,
  bit[92] = 514, bit[93] = 2052, bit[94] = 32770, bit[95] = 264, bit[96] = 6,
  bit[97] = 33554432, bit[98] = 18, bit[99] = 36, bit[100] = 10,
  bit[101] = 67108864, bit[102] = 134, bit[103] = 134217728, bit[104] = 66,
  bit[105] = 28, bit[106] = 65538, bit[107] = 268435456, bit[108] = 6,
  bit[109] = 536870912, bit[110] = 42, bit[111] = 4100, bit[112] = 18,
  bit[113] = 1073741824, bit[114] = 262, bit[115] = 520, bit[116] = 1026,
  bit[117] = 68, bit[118] = 131074, bit[119] = 144, bit[120] = 14,
  bit[121] = 32, bit[122] = 262146, bit[123] = 8196, bit[124] = 2050,
  bit[125] = 8, bit[126] = 22, bit[127] = 2147483648, bit[128] = 2,
  bit[129] = 16388, bit[130] = 74, bit[131] = 4294967296, bit[132] = 38,
  bit[133] = 272, bit[134] = 524290, bit[135] = 12, bit[136] = 130,
  bit[137] = 8589934592, bit[138] = 518, bit[139] = 17179869184, bit[140] = 26,
  bit[141] = 32772, bit[142] = 1048578, bit[143] = 96, bit[144] = 6,
  bit[145] = 1032, bit[146] = 2097154, bit[147] = 20, bit[148] = 4098,
  bit[149] = 34359738368, bit[150] = 14, bit[151] = 68719476736, bit[152] = 258,
  bit[153] = 132, bit[154] = 50, bit[155] = 2056, bit[156] = 70,
  bit[157] = 137438953472, bit[158] = 4194306, bit[159] = 65540, bit[160] = 10,
  bit[161] = 528, bit[162] = 6, bit[163] = 274877906944, bit[164] = 8194,
  bit[165] = 44, bit[166] = 8388610, bit[167] = 549755813888, bit[168] = 22,
  bit[169] = 64, bit[170] = 138, bit[171] = 260, bit[172] = 16386,
  bit[173] = 1099511627776, bit[174] = 1030, bit[175] = 24, bit[176] = 34,
  bit[177] = 131076, bit[178] = 16777218, bit[179] = 2199023255552,
  bit[180] = 14, bit[181] = 4398046511104, bit[182] = 82, bit[183] = 262148,
  bit[184] = 514, bit[185] = 4104, bit[186] = 2054, bit[187] = 160,
  bit[188] = 32770, bit[189] = 20, bit[190] = 266, bit[191] = 8796093022208,
  bit[192] = 6, bit[193] = 17592186044416, bit[194] = 33554434, bit[195] = 76,
  bit[196] = 18, bit[197] = 35184372088832, bit[198] = 38,
  bit[199] = 70368744177664, bit[200] = 10, bit[201] = 524292,
  bit[202] = 67108866, bit[203] = 1040, bit[204] = 134, bit[205] = 8200,
  bit[206] = 134217730, bit[207] = 516, bit[208] = 66, bit[209] = 288,
  bit[210] = 30, bit[211] = 140737488355328, bit[212] = 65538,
  bit[213] = 1048580, bit[214] = 268435458, bit[215] = 16392, bit[216] = 6,
  bit[217] = 2064, bit[218] = 536870914, bit[219] = 2097156, bit[220] = 42,
  bit[221] = 192, bit[222] = 4102, bit[223] = 281474976710656, bit[224] = 18,
  bit[225] = 12, bit[226] = 1073741826, bit[227] = 562949953421312,
  bit[228] = 262, bit[229] = 1125899906842624, bit[230] = 522, bit[231] = 52,
  bit[232] = 1026, bit[233] = 2251799813685248, bit[234] = 70, bit[235] = 32776,
  bit[236] = 131074, bit[237] = 4194308, bit[238] = 146,
  bit[239] = 4503599627370496, bit[240] = 14, bit[241] = 9007199254740992,
  bit[242] = 34, bit[243] = 4, bit[244] = 262146, bit[245] = 24,
  bit[246] = 8198, bit[247] = 320, bit[248] = 2050, bit[249] = 8388612,
  bit[250] = 10, bit[251] = 18014398509481984, bit[252] = 22, bit[253] = 544,
  bit[254] = 2147483650, bit[255] = 140, bit[256] = 2,
  bit[257] = 36028797018963968, bit[258] = 16390, bit[259] = 4112,
  bit[260] = 74, bit[261] = 1028, bit[262] = 4294967298,
  bit[263] = 72057594037927936, bit[264] = 38, bit[265] = 65544, bit[266] = 274,
  bit[267] = 16777220, bit[268] = 524290, bit[269] = 144115188075855872,
  bit[270] = 14, bit[271] = 288230376151711744, bit[272] = 130, bit[273] = 84,
  bit[274] = 8589934594, bit[275] = 40, bit[276] = 518,
  bit[277] = 576460752303423488, bit[278] = 17179869186, bit[279] = 2052,
  bit[280] = 26, bit[281] = 1152921504606846976, bit[282] = 32774,
  bit[283] = 2305843009213693952, bit[284] = 1048578, bit[285] = 268,
  bit[286] = 98, bit[287] = 8208, bit[288] = 6, bit[289] = 128, bit[290] = 1034,
  bit[291] = 33554436, bit[292] = 2097154, bit[293] = 4611686018427387904,
  bit[294] = 22, bit[295] = 131080, bit[296] = 4098, bit[297] = 36,
  bit[298] = 34359738370, bit[299] = 576, bit[300] = 14;
}
struct node {
  long long l, r;
  long long tag1, s1, s2, tag2;
} tr[maxn];
long long n, q, l, r;
long long v, ans, pos;
char s[maxn];
long long power(long long a, long long b) {
  long long ret = 1;
  for (; b; b >>= 1, (a *= a) %= mod)
    if (b & 1) (ret *= a) %= mod;
  return ret;
}
void build(long long t, long long l, long long r) {
  tr[t].l = l, tr[t].r = r, tr[t].tag1 = 1;
  if (l == r) {
    read(tr[t].s1);
    tr[t].s2 = bit[tr[t].s1];
    return;
  }
  long long mid = (l + r) >> 1;
  build(t << 1, l, mid);
  build(t << 1 | 1, mid + 1, r);
  tr[t].s1 = tr[t << 1].s1 * tr[t << 1 | 1].s1 % mod;
  tr[t].s2 = tr[t << 1].s2 | tr[t << 1 | 1].s2;
  return;
}
void dtag_tags(long long t, long long v) {
  tr[t].tag2 |= v;
  tr[t].s2 |= v;
  return;
}
void push_tags(long long t) {
  dtag_tags(t << 1, tr[t].tag2);
  dtag_tags(t << 1 | 1, tr[t].tag2);
  tr[t].tag2 = 0;
  return;
}
void modify_tags(long long t, long long l, long long r, long long v) {
  if (tr[t].l >= l && tr[t].r <= r) {
    dtag_tags(t, v);
    return;
  }
  if (tr[t].tag2) push_tags(t);
  long long mid = (tr[t].l + tr[t].r) >> 1;
  if (l <= mid) modify_tags(t << 1, l, r, v);
  if (r > mid) modify_tags(t << 1 | 1, l, r, v);
  tr[t].s2 = tr[t << 1].s2 | tr[t << 1 | 1].s2;
  return;
}
long long query_tags(long long t, long long l, long long r) {
  if (tr[t].l >= l && tr[t].r <= r) return tr[t].s2;
  if (tr[t].tag2) push_tags(t);
  long long mid = (tr[t].l + tr[t].r) >> 1;
  long long ret = 0;
  if (l <= mid) ret |= query_tags(t << 1, l, r);
  if (r > mid) ret |= query_tags(t << 1 | 1, l, r);
  return ret;
}
void dtag_mul(long long t, long long v) {
  (tr[t].tag1 *= v) %= mod;
  (tr[t].s1 *= power(v, static_cast<long long>(tr[t].r - tr[t].l + 1))) %= mod;
  return;
}
void push_mul(long long t) {
  dtag_mul(t << 1, tr[t].tag1);
  dtag_mul(t << 1 | 1, tr[t].tag1);
  tr[t].tag1 = 1;
}
void modify_mul(long long t, long long l, long long r, long long v) {
  if (tr[t].r <= r && tr[t].l >= l) {
    dtag_mul(t, v);
    return;
  }
  if (tr[t].tag1) push_mul(t);
  long long mid = (tr[t].l + tr[t].r) >> 1;
  if (l <= mid) modify_mul(t << 1, l, r, v);
  if (r > mid) modify_mul(t << 1 | 1, l, r, v);
  tr[t].s1 = tr[t << 1].s1 * tr[t << 1 | 1].s1 % mod;
  return;
}
long long query_mul(long long t, long long l, long long r) {
  if (tr[t].l >= l && tr[t].r <= r) return tr[t].s1;
  if (tr[t].tag1) push_mul(t);
  long long mid = (tr[t].r + tr[t].l) >> 1;
  long long ret = 1;
  if (l <= mid) (ret *= query_mul(t << 1, l, r)) %= mod;
  if (r > mid) (ret *= query_mul(t << 1 | 1, l, r)) %= mod;
  return ret;
}
long long calc(long long ans, long long pos) {
  long long sum = 1;
  while (sum <= 63LL) {
    if (pos & (1LL << (sum))) {
      (ans *= prime[sum] - 1) %= mod;
      (ans *= inv[sum]) %= mod;
    }
    sum++;
  }
  return ans;
}
signed main() {
  init();
  read(n), read(q);
  build(1, 1, n);
  while (q--) {
    scanf("%s", s + 1);
    if (s[1] == 'M') {
      read(l), read(r), read(v);
      modify_mul(1, l, r, v);
      modify_tags(1, l, r, bit[v]);
      continue;
    } else {
      read(l), read(r);
      ans = query_mul(1, l, r);
      pos = query_tags(1, l, r);
      printf("%lld\n", calc(ans, pos));
    }
  }
  return 0;
}
