#include <bits/stdc++.h>
using namespace std;
inline long long mul(long long a, long long b) { return (a * b) % 1000000007; }
long long bp(long long b, long long p) {
  long long ac = 1;
  while (p > 0) {
    if (p & 1) {
      ac = mul(ac, b);
    }
    b = mul(b, b);
    p /= 2;
  }
  return ac;
}
int pl[300];
int rpl[300];
bool prm(int n) {
  if (n < 2) {
    return false;
  }
  if (n <= 3) {
    return true;
  }
  if (!(n % 2) || !(n % 3)) {
    return false;
  }
  for (int i = 5; i * i <= n; i += 6) {
    if (!(n % i) || !(n % (i + 2))) {
      return false;
    }
  }
  return true;
}
long long dpf[400];
long long fac(int b) {
  long long og = b;
  if (b <= 300 && dpf[b] != -1) {
    return dpf[b];
  }
  long long res = 0;
  for (int id = 0; rpl[id] * rpl[id] <= b; id++) {
    while (!(b % rpl[id])) {
      b /= (rpl[id]);
      res |= (1LL << id);
    }
  }
  if (b > 1) {
    res |= (1LL << pl[b]);
  }
  if (og <= 300) {
    dpf[og] = res;
  }
  return res;
}
void init() {
  memset(pl, -1, sizeof(pl));
  int ct = 0;
  for (int i = 0; i < 300; i++) {
    if (prm(i)) {
      pl[i] = ct;
      rpl[ct] = i;
      ct++;
    }
  }
}
long long dpi[400];
long long inv(long long v) {
  if (dpi[v] != -1) {
    return dpi[v];
  }
  return dpi[v] = bp(v, 1000000007 - 2);
}
class ST {
 private:
  vector<long long> bs, st, A, lzb, lzs;
  int n;
  int lf(int p) { return p << 1; }
  int rt(int p) { return 1 + (p << 1); }
  void build(int p, int l, int r) {
    if (l == r) {
      st[p] = A[l];
      bs[p] = fac(A[l]);
      return;
    }
    int m = (l + r) / 2;
    build(lf(p), l, m);
    build(rt(p), m + 1, r);
    st[p] = mul(st[lf(p)], st[rt(p)]);
    bs[p] = bs[lf(p)] | bs[rt(p)];
  }
  void upS(int p, int l, int r, int i, int j, long long v) {
    if (lzs[p] != 1) {
      st[p] = mul(st[p], bp(lzs[p], r - l + 1));
      if (l != r) {
        lzs[lf(p)] = mul(lzs[lf(p)], lzs[p]);
        lzs[rt(p)] = mul(lzs[rt(p)], lzs[p]);
      }
      lzs[p] = 1;
    }
    if (l > j || r < i) {
      return;
    }
    if (l == r) {
      st[p] = mul(st[p], v);
      return;
    }
    if (l >= i && r <= j) {
      st[p] = mul(st[p], bp(v, r - l + 1));
      lzs[lf(p)] = mul(lzs[lf(p)], v);
      lzs[rt(p)] = mul(lzs[rt(p)], v);
      return;
    }
    int m = (l + r) / 2;
    upS(lf(p), l, m, i, j, v);
    upS(rt(p), m + 1, r, i, j, v);
    st[p] = mul(st[lf(p)], st[rt(p)]);
  }
  void upB(int p, int l, int r, int i, int j, long long v) {
    if (lzb[p] != 0) {
      bs[p] |= lzb[p];
      if (l != r) {
        lzb[lf(p)] |= lzb[p];
        lzb[rt(p)] |= lzb[p];
      }
      lzb[p] = 0;
    }
    if (l > j || r < i) {
      return;
    }
    if (l == r) {
      bs[p] |= v;
      return;
    }
    if (l >= i && r <= j) {
      bs[p] |= v;
      lzb[lf(p)] |= v;
      lzb[rt(p)] |= v;
      return;
    }
    int m = (l + r) / 2;
    upB(lf(p), l, m, i, j, v);
    upB(rt(p), m + 1, r, i, j, v);
    bs[p] = bs[lf(p)] | bs[rt(p)];
  }
  long long cinv(long long bv) {
    long long res = 1;
    for (int i = 0; i < 62; i++) {
      if ((1LL << i) & bv) {
        res = mul(res, inv(rpl[i]));
        res = mul(res, rpl[i] - 1);
      }
    }
    return res;
  }
  pair<long long, long long> tot(int p, int l, int r, int i, int j) {
    if (l > j || r < i) {
      return make_pair(1, 0);
    }
    if (lzs[p] != 1) {
      st[p] = mul(st[p], bp(lzs[p], r - l + 1));
      if (l != r) {
        lzs[lf(p)] = mul(lzs[lf(p)], lzs[p]);
        lzs[rt(p)] = mul(lzs[rt(p)], lzs[p]);
      }
      lzs[p] = 1;
    }
    if (lzb[p] != 0) {
      bs[p] |= lzb[p];
      if (l != r) {
        lzb[lf(p)] |= lzb[p];
        lzb[rt(p)] |= lzb[p];
      }
      lzb[p] = 0;
    }
    if (l >= i && r <= j) {
      return make_pair(st[p], bs[p]);
    }
    if (l == r) {
      return make_pair(st[p], bs[p]);
    }
    pair<long long, long long> rl, rr;
    int m = (l + r) / 2;
    rl = tot(lf(p), l, m, i, j);
    rr = tot(rt(p), m + 1, r, i, j);
    pair<long long, long long> res =
        make_pair(mul(rr.first, rl.first), (rl.second | rr.second));
    return make_pair(mul(rr.first, rl.first), (rl.second | rr.second));
  }

 public:
  ST(vector<long long> _A) {
    A = _A;
    n = A.size();
    st.assign(4 * n, 1);
    bs.assign(4 * n, 0);
    lzb.assign(4 * n, 0);
    lzs.assign(4 * n, 1);
    build(1, 0, n - 1);
  }
  void mult(int i, int j, int val) {
    long long bv = 0;
    bv |= fac(val);
    upB(1, 0, n - 1, i, j, bv);
    upS(1, 0, n - 1, i, j, val);
  }
  long long tot(int i, int j) {
    pair<long long, long long> pre = tot(1, 0, n - 1, i, j);
    return mul(pre.first, cinv(pre.second));
  }
};
int main() {
  ios::sync_with_stdio(0);
  memset(dpf, -1, sizeof(dpf));
  memset(dpi, -1, sizeof(dpi));
  int n, q;
  cin >> n >> q;
  vector<long long> v;
  init();
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    v.push_back(t);
  }
  ST st(v);
  char s[300];
  while (q--) {
    int l, r;
    cin >> s >> l >> r;
    l--;
    r--;
    if (s[0] == 'M') {
      int mv;
      cin >> mv;
      st.mult(l, r, mv);
    } else {
      long long rv = st.tot(l, r);
      cout << rv % 1000000007 << '\n';
    }
  }
}
