#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1);
const int LIN = 4e5 + 8;
int n, q;
vector<int> pr;
long long state, prod;
long long t[LIN << 2], p[LIN << 2], ft[LIN << 2], fp[LIN << 2], mask[301],
    inv[301];
char s[10];
int bit(long long x, int i) { return (x >> i) & 1; }
long long powr(long long a, long long x) {
  long long r = 1;
  for (; x; x >>= 1) {
    if (x & 1) r = r * a % MOD;
    a = a * a % MOD;
  }
  return r;
}
bool isprime(int x) {
  for (int i = 2; i < x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
void init(int k, int l, int r) {
  t[k] = 1;
  ft[k] = 1;
  if (l < r) {
    int m = (l + r) >> 1;
    init(k << 1, l, m);
    init(k << 1 ^ 1, m + 1, r);
  }
}
void lazy(int k, int l, int r) {
  t[k] = (t[k] * powr(ft[k], r - l + 1)) % MOD;
  p[k] |= fp[k];
  if (l < r) {
    ft[k << 1] = (ft[k << 1] * ft[k]) % MOD;
    ft[k << 1 ^ 1] = (ft[k << 1 ^ 1] * ft[k]) % MOD;
    fp[k << 1] |= fp[k];
    fp[k << 1 ^ 1] |= fp[k];
  }
  ft[k] = 1;
  fp[k] = 0;
}
void update(int k, int l, int r, int x, int y, long long v, long long b) {
  lazy(k, l, r);
  if (l > y || r < x) return;
  if (l >= x && r <= y) {
    ft[k] = (ft[k] * v) % MOD;
    fp[k] |= b;
    lazy(k, l, r);
    return;
  }
  int m = (l + r) >> 1;
  update(k << 1, l, m, x, y, v, b);
  update(k << 1 ^ 1, m + 1, r, x, y, v, b);
  t[k] = (t[k << 1] * t[k << 1 ^ 1]) % MOD;
  p[k] = p[k << 1] | p[k << 1 ^ 1];
}
void get(int k, int l, int r, int x, int y) {
  lazy(k, l, r);
  if (l > y || r < x) return;
  if (l >= x && r <= y) {
    prod = (prod * t[k]) % MOD;
    state |= p[k];
    return;
  }
  int m = (l + r) >> 1;
  get(k << 1, l, m, x, y);
  get(k << 1 ^ 1, m + 1, r, x, y);
}
int totient() {
  long long res = prod;
  for (int i = 0; i < 62; i++) {
    if (bit(state, i)) {
      res = (res * (pr[i] - 1)) % MOD;
      res = (res * inv[pr[i]]) % MOD;
    }
  }
  return res;
}
void init(int test_number) {
  for (int i = 2; i < 300; i++)
    if (isprime(i)) pr.push_back(i);
  for (int i = 1; i <= 300; i++) {
    for (int j = 0; j < 62; j++) {
      if (i % pr[j] == 0) {
        mask[i] |= (1ll << j);
      }
    }
    inv[i] = powr(i, MOD - 2);
  }
}
void solve(int test_number) {
  scanf("%d %d", &n, &q);
  init(1, 1, n);
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    update(1, 1, n, i, i, a, mask[a]);
  }
  while (q--) {
    int l, r;
    scanf("%s %d %d", s, &l, &r);
    if (s[0] == 'T') {
      state = 0;
      prod = 1;
      get(1, 1, n, l, r);
      printf("%d\n", totient());
    } else {
      int x;
      scanf("%d", &x);
      update(1, 1, n, l, r, x, mask[x]);
    }
  }
}
void init() {}
void solve() {
  init();
  int test = 1;
  for (int i = 1; i <= test; i++) init(i), solve(i);
}
int main() {
  solve();
  return 0;
}
