#include <bits/stdc++.h>
using namespace std;
;
const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 4e5 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
char op[15];
long long inv[305];
long long ans1, ans2;
int p[305], isp[63];
int n, q, m, l, r, x;
long long qpow(long long x, int n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
void init() {
  for (int i = 2; i <= 300; i++) p[i] = 1;
  for (int i = 2; i * i <= 300; i++) {
    if (p[i]) {
      for (int j = i * i; j <= 300; j += i) {
        p[j] = 0;
      }
    }
  }
  for (int i = 2; i <= 300; i++)
    if (p[i]) isp[m++] = i;
  for (int i = 0; i < 62; i++) inv[i] = qpow(isp[i], mod - 2);
}
struct node {
  int l, r;
  long long lazy1, lazy2, sum, pp;
} segtree[maxn << 2];
void push_up(int rt) {
  segtree[rt].sum = segtree[rt << 1].sum * segtree[rt << 1 | 1].sum % mod;
  segtree[rt].pp = segtree[rt << 1].pp | segtree[rt << 1 | 1].pp;
}
void push_down(int rt) {
  long long x = segtree[rt].lazy1;
  (segtree[rt << 1].lazy1 *= x) %= mod;
  (segtree[rt << 1 | 1].lazy1 *= x) %= mod;
  (segtree[rt << 1].sum *=
   qpow(x, segtree[rt << 1].r - segtree[rt << 1].l + 1)) %= mod;
  (segtree[rt << 1 | 1].sum *=
   qpow(x, segtree[rt << 1 | 1].r - segtree[rt << 1 | 1].l + 1)) %= mod;
  segtree[rt].lazy1 = 1;
  x = segtree[rt].lazy2;
  segtree[rt << 1].lazy2 |= x;
  segtree[rt << 1 | 1].lazy2 |= x;
  segtree[rt << 1].pp |= x;
  segtree[rt << 1 | 1].pp |= x;
  segtree[rt].lazy2 = 0;
}
void build(int rt, int l, int r) {
  segtree[rt].l = l, segtree[rt].r = r;
  segtree[rt].sum = segtree[rt].pp = 0;
  segtree[rt].lazy1 = 1, segtree[rt].lazy2 = 0;
  if (l == r) {
    scanf("%lld", &segtree[rt].sum);
    for (int i = 0; i < 62; i++) {
      if (segtree[rt].sum % isp[i] == 0) segtree[rt].pp |= (1LL << i);
    }
    return;
  }
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  push_up(rt);
}
void update(int rt, int l, int r, int x) {
  if (segtree[rt].l == l && segtree[rt].r == r) {
    (segtree[rt].sum *= qpow(x, segtree[rt].r - segtree[rt].l + 1)) %= mod;
    (segtree[rt].lazy1 *= x) %= mod;
    for (int i = 0; i < 62; i++) {
      if (x % isp[i] == 0)
        segtree[rt].pp |= (1LL << i), segtree[rt].lazy2 |= (1LL << i);
    }
    return;
  }
  push_down(rt);
  int mid = (segtree[rt].l + segtree[rt].r) >> 1;
  if (r <= mid)
    update(rt << 1, l, r, x);
  else if (l > mid)
    update(rt << 1 | 1, l, r, x);
  else {
    update(rt << 1, l, mid, x);
    update(rt << 1 | 1, mid + 1, r, x);
  }
  push_up(rt);
}
void query(int rt, int l, int r) {
  if (segtree[rt].l == l && segtree[rt].r == r) {
    (ans1 *= segtree[rt].sum) %= mod;
    ans2 |= segtree[rt].pp;
    return;
  }
  push_down(rt);
  int mid = (segtree[rt].l + segtree[rt].r) >> 1;
  if (r <= mid)
    query(rt << 1, l, r);
  else if (l > mid)
    query(rt << 1 | 1, l, r);
  else {
    query(rt << 1, l, mid);
    query(rt << 1 | 1, mid + 1, r);
  }
}
int main() {
  init();
  scanf("%d%d", &n, &q);
  build(1, 1, n);
  while (q--) {
    scanf("%s%d%d", op, &l, &r);
    if (op[0] == 'T') {
      ans1 = 1, ans2 = 0;
      query(1, l, r);
      for (int i = 0; i < 62; i++) {
        if (ans2 & (1LL << i)) {
          ans1 = ans1 * (isp[i] - 1) % mod * inv[i] % mod;
        }
      }
      printf("%lld\n", ans1);
    } else {
      scanf("%d", &x);
      update(1, l, r, x);
    }
  }
  return 0;
}
