#include <bits/stdc++.h>
using namespace std;
int add(int x, int y) {
  return ((x + y) % 1000000007 + 1000000007) % 1000000007;
}
int mul(int x, int y) { return (long long)x * y % 1000000007; }
int mypow(int x, int c) {
  int ret = 1;
  while (c > 0) {
    if (c & 1) {
      ret = mul(ret, x);
    }
    c /= 2;
    x = mul(x, x);
  }
  return ret;
}
vector<int> plist[305];
int seg[400005 * 4], lazy[400005 * 4];
int a[400005];
void init(int pos, int l, int r) {
  lazy[pos] = 1;
  if (l == r) {
    seg[pos] = a[l];
    return;
  }
  int mid = (l + r) / 2;
  init(pos * 2, l, mid);
  init(pos * 2 + 1, mid + 1, r);
  seg[pos] = mul(seg[pos * 2], seg[pos * 2 + 1]);
}
void push(int pos, int l, int r) {
  if (lazy[pos] != 1) {
    seg[pos] = mul(mypow(lazy[pos], r - l + 1), seg[pos]);
    if (l != r) {
      lazy[pos * 2] = mul(lazy[pos], lazy[pos * 2]);
      lazy[pos * 2 + 1] = mul(lazy[pos], lazy[pos * 2 + 1]);
    }
    lazy[pos] = 1;
  }
}
void update(int pos, int l, int r, int ql, int qr, int val) {
  push(pos, l, r);
  if (r < ql || qr < l) {
    return;
  }
  if (ql <= l && r <= qr) {
    lazy[pos] = val;
    push(pos, l, r);
    return;
  }
  int mid = (l + r) / 2;
  update(pos * 2, l, mid, ql, qr, val);
  update(pos * 2 + 1, mid + 1, r, ql, qr, val);
  seg[pos] = mul(seg[pos * 2], seg[pos * 2 + 1]);
}
int query(int pos, int l, int r, int ql, int qr) {
  push(pos, l, r);
  if (r < ql || qr < l) {
    return 1;
  }
  if (ql <= l && r <= qr) {
    return seg[pos];
  }
  int mid = (l + r) / 2;
  return mul(query(pos * 2, l, mid, ql, qr),
             query(pos * 2 + 1, mid + 1, r, ql, qr));
}
int value[305], mm[305];
int pen[65][400005];
void update(int ind, int p) {
  while (ind < 400005) {
    pen[p][ind] += 1;
    ind += ind & (-ind);
  }
}
int query(int ind, int p) {
  int ret = 0;
  while (ind > 0) {
    ret += pen[p][ind];
    ind = ind & (ind - 1);
  }
  return ret;
}
void find(int p, int l, int r) {
  int v = query(l - 1, p);
  while (true) {
    int nind, ind = 0;
    int sum = 0;
    for (int i = 18; i >= 0; --i) {
      nind = (1 << i) + ind;
      if (nind <= l - 1 ||
          (nind >= l && sum + pen[p][nind] == v + nind - l + 1)) {
        ind = nind;
        sum += pen[p][nind];
      }
    }
    if (ind + 1 <= r) {
      update(ind + 1, p);
    } else {
      break;
    }
  }
}
void solve() {
  int cc = 0;
  for (int i = 2; i < 305; ++i) {
    if (plist[i].size() == 0) {
      for (int j = i; j < 305; j += i) {
        plist[j].push_back(i);
      }
      value[i] = cc;
      mm[cc++] = mul(i - 1, mypow(i, 1000000007 - 2));
    }
  }
  int n, q;
  scanf("%d %d ", &n, &q);
  for (int i = 1; i <= n; ++i) {
    scanf("%d ", &a[i]);
    for (int x : plist[a[i]]) {
      find(value[x], i, i);
    }
  }
  init(1, 1, n);
  char op[100];
  int l, r;
  while (q--) {
    scanf(" %s %d %d ", op, &l, &r);
    if (op[0] == 'T') {
      int ret = query(1, 1, n, l, r);
      for (int i = 0; i < cc; ++i) {
        if (query(r, i) - query(l - 1, i) > 0) {
          ret = mul(ret, mm[i]);
        }
      }
      printf("%d\n", ret);
    } else {
      int x;
      scanf("%d ", &x);
      update(1, 1, n, l, r, x);
      for (int p : plist[x]) {
        find(value[p], l, r);
      }
    }
  }
}
int main() {
  solve();
  return 0;
}
