#include <bits/stdc++.h>
using namespace std;
int p[305];
bool np[305];
struct qnode {
  int opt, l, r, x;
} q[400000 + 5];
int a[400000 + 5];
long long inv[305];
long long qp(long long a, int k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
    k >>= 1;
  }
  return res;
}
struct SEGTREEmul {
  long long s[400000 * 4 + 5], mark[400000 * 4 + 5];
  void pu(int i) { s[i] = s[i * 2] * s[i * 2 + 1] % 1000000007; }
  void pd(int i, int l, int r) {
    if (mark[i] != 1) {
      mark[i * 2] = mark[i * 2] * mark[i] % 1000000007;
      mark[i * 2 + 1] = mark[i * 2 + 1] * mark[i] % 1000000007;
      int mid = (l + r) >> 1;
      s[i * 2] = s[i * 2] * qp(mark[i], mid - l + 1) % 1000000007;
      s[i * 2 + 1] = s[i * 2 + 1] * qp(mark[i], r - mid) % 1000000007;
      mark[i] = 1;
    }
  }
  void build(int i, int l, int r) {
    mark[i] = 1;
    if (l == r)
      s[i] = a[l];
    else {
      int mid = (l + r) >> 1;
      build(i * 2, l, mid);
      build(i * 2 + 1, mid + 1, r);
      pu(i);
    }
  }
  void add(int i, int l, int r, int ql, int qr, int x) {
    if (ql <= l && r <= qr) {
      s[i] = s[i] * qp(x, r - l + 1) % 1000000007;
      mark[i] = mark[i] * x % 1000000007;
      return;
    }
    if (qr < l || r < ql) return;
    pd(i, l, r);
    int mid = (l + r) >> 1;
    add(i * 2, l, mid, ql, qr, x);
    add(i * 2 + 1, mid + 1, r, ql, qr, x);
    pu(i);
  }
  long long ask(int i, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return s[i];
    if (qr < l || r < ql) return 1;
    pd(i, l, r);
    int mid = (l + r) >> 1;
    return ask(i * 2, l, mid, ql, qr) * ask(i * 2 + 1, mid + 1, r, ql, qr) %
           1000000007;
  }
} tmul;
struct SEGTREEflag {
  bool s[400000 * 4 + 5], mark[400000 * 4 + 5];
  void pu(int i) { s[i] = s[i * 2] || s[i * 2 + 1]; }
  void pd(int i) {
    if (mark[i]) {
      mark[i * 2] = mark[i * 2 + 1] = 1;
      s[i * 2] = s[i * 2 + 1] = 1;
      mark[i] = 0;
    }
  }
  void build(int i, int l, int r, int pr) {
    mark[i] = 0;
    if (l == r)
      s[i] = a[l] % pr == 0;
    else {
      int mid = (l + r) >> 1;
      build(i * 2, l, mid, pr);
      build(i * 2 + 1, mid + 1, r, pr);
      pu(i);
    }
  }
  void set(int i, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) {
      s[i] = 1;
      mark[i] = 1;
      return;
    }
    if (qr < l || r < ql) return;
    pd(i);
    int mid = (l + r) >> 1;
    set(i * 2, l, mid, ql, qr);
    set(i * 2 + 1, mid + 1, r, ql, qr);
    pu(i);
  }
  bool ask(int i, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return s[i];
    if (qr < l || r < ql) return 0;
    pd(i);
    int mid = (l + r) >> 1;
    return ask(i * 2, l, mid, ql, qr) || ask(i * 2 + 1, mid + 1, r, ql, qr);
  }
} tf;
long long ans[400000 + 5];
int main() {
  int num = 0;
  for (int i = 2; i <= 300; i++)
    if (np[i] == 0) {
      p[++num] = i;
      for (int j = i * 2; j <= 300; j += i) np[j] = 1;
    }
  inv[1] = 1;
  for (int i = 2; i <= 300; i++)
    inv[i] = inv[1000000007 % i] * (1000000007 - 1000000007 / i) % 1000000007;
  int n, Q;
  scanf("%d%d", &n, &Q);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= Q; i++) {
    char s[15];
    scanf("%s%d%d", s, &q[i].l, &q[i].r);
    if (s[0] == 'T')
      q[i].opt = 2;
    else {
      q[i].opt = 1;
      scanf("%d", &q[i].x);
    }
  }
  tmul.build(1, 1, n);
  for (int i = 1; i <= Q; i++) ans[i] = 1;
  for (int i = 1; i <= Q; i++) {
    if (q[i].opt == 1)
      tmul.add(1, 1, n, q[i].l, q[i].r, q[i].x);
    else
      ans[i] = ans[i] * tmul.ask(1, 1, n, q[i].l, q[i].r);
  }
  for (int r = 1; r <= num; r++) {
    int pr = p[r];
    tf.build(1, 1, n, pr);
    for (int i = 1; i <= Q; i++) {
      if (q[i].opt == 1) {
        if (q[i].x % pr == 0) tf.set(1, 1, n, q[i].l, q[i].r);
      } else {
        if (tf.ask(1, 1, n, q[i].l, q[i].r))
          ans[i] = ans[i] * (1 - inv[pr] + 1000000007) % 1000000007;
      }
    }
  }
  for (int i = 1; i <= Q; i++)
    if (q[i].opt == 2) printf("%I64d\n", ans[i]);
  return 0;
}
