#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   const long long INF = 0x3f3f3f3f3f3f3f3f;   const long long llinf = (1LL << 61);   const int inf = (1 << 30);   const int nmax = 4e5 + 50;   const int mod = 1e9 + 7;   using namespace std;   string s;   long long n, a[nmax], st[4 * nmax], i, lzy[4 * nmax], x, q, st1[4 * nmax],       ms[4 * nmax], msk[nmax], m, ans, j, inv[100], l, r, sv[500], x1;   long long pr[] = {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};   long long pw(long long n, long long p) {     long long tmp = n, ans = 1, mx;     if (p == mod - 2)       mx = 31;     else       mx = 18;     for (int i = 0; i <= mx; i++) {       if (p & (1LL << i)) ans = (ans * tmp) % mod;       tmp = (tmp * tmp) % mod;     }     return ans;   }   void build(int x, int l, int r) {     if (l == r) {       st[x] = a[l];       st1[x] = msk[l];       return;     }     int mid = (l + r) / 2;     build(2 * x, l, mid);     build(2 * x + 1, mid + 1, r);     st[x] = st[2 * x] * st[2 * x + 1];     st[x] %= mod;     st1[x] = st1[2 * x] | st1[2 * x + 1];   }   void push(int nod, int l, int r) {     if (!lzy[nod]) return;     if (lzy[nod] != 1) st[nod] = (st[nod] * pw(lzy[nod], r - l + 1)) % mod;     st1[nod] |= ms[nod];     if (l != r) {       if (lzy[nod] != 1) {         lzy[nod * 2] *= lzy[nod];         lzy[nod * 2 + 1] *= lzy[nod];         lzy[nod * 2] %= mod;         lzy[nod * 2 + 1] %= mod;       }       ms[nod * 2] |= ms[nod];       ms[nod * 2 + 1] |= ms[nod];     }     lzy[nod] = 1;   }   void upd(int nod, int l, int r, int tl, int tr, long long v, long long m) {     push(nod, l, r);     if (tl <= l && r <= tr) {       lzy[nod] = (lzy[nod] * v) % mod;       ms[nod] |= m;       push(nod, l, r);       return;     }     int mid = (l + r) / 2;     if (tl <= mid) upd(nod * 2, l, mid, tl, tr, v, m);     if (mid < tr) upd(nod * 2 + 1, mid + 1, r, tl, tr, v, m);     push(nod * 2, l, mid);     push(nod * 2 + 1, mid + 1, r);     st[nod] = st[nod * 2] * st[nod * 2 + 1];     st[nod] %= mod;     st1[nod] = st1[nod * 2] | st1[nod * 2 + 1];   }   pair<long long, long long> qry(int nod, int l, int r, int tl, int tr) {     push(nod, l, r);     if (tl <= l && r <= tr) return {st[nod], st1[nod]};     int mid = (l + r) / 2;     pair<long long, long long> vl, x;     vl.first = 1, vl.second = 0;     if (tl <= mid) {       x = qry(nod * 2, l, mid, tl, tr);       vl.first = (vl.first * x.first) % mod;       vl.second |= x.second;     }     if (mid < tr) {       x = qry(nod * 2 + 1, mid + 1, r, tl, tr);       vl.first = (vl.first * x.first) % mod;       vl.second |= x.second;     }     return vl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cerr.tie(0);     cout.tie(0);     cin >> n >> q;     for (j = 0; j < 62; j++) {       inv[j] = pw(pr[j], mod - 2);       sv[pr[j]] = j;     }     for (i = 1; i <= n; i++) {       cin >> a[i];       for (j = 0; j < 62; j++)         if (a[i] % pr[j] == 0) msk[i] |= (1LL << j);     }     for (i = 1; i <= 1600000; i++) lzy[i] = 1;     build(1, 1, n);     while (q--) {       cin >> s;       if (s[0] ==  M ) {         cin >> l >> r >> x;         x1 = x, m = 0;         for (j = 0; j < 62; j++)           if (x % pr[j] == 0) m |= (1LL << j);         upd(1, 1, n, l, r, x, m);       } else {         cin >> l >> r;         pair<long long, long long> p = qry(1, 1, n, l, r);         ans = p.first;         for (j = 0; j < 62; j++) {           if (p.second & (1LL << j)) {             ans = (ans * (1 - inv[j] + mod)) % mod;           }         }         cout << ans << endl;       }     }     return 0;   }