if (ql <= mid) update(ql, qr, w, pos << 1, l, mid); if (qr > mid) update(ql, qr, w, pos << 1 | 1, mid + 1, r); pushup(pos); } } T2; ll p[N], cnt = -1; ll vis[N]; intmain() { for (ll i = 2; i <= 300; i++) { bool flag = 1; for (ll j = 2; j < i; j++) if (i % j == 0) flag = 0;
if (flag) p[++cnt] = i, vis[cnt] = (1 - qpow(i, mod - 2, mod) + mod) % mod; }
ll n = read(), m = read(); for (ll i = 1; i <= 4 * n; i++) T2.sum[i] = T2.lazy[i] = 1; for (ll i = 1; i <= n; i++) { ll x = read(); ll st = 0; for (ll j = 0; j <= cnt; j++) if (x % p[j] == 0) st |= (1ll << j); //cout << x << " " << st << endl; T1.update(i, i, st, 1, 1, n); T2.update(i, i, x, 1, 1, n); }
for (ll t = 1; t <= m; t++) { char s[10]; scanf("%s", s); //cout << "---" << endl; if (s[0] == 'T') { ll l = read(), r = read(); ll ans = 1; //cout << l << " " << r << endl; ll st = T1.query(l, r, 1, 1, n);
for (ll i = 0; i <= cnt; i++) if ((st & (1ll << i))) ans = 1ll * ans * vis[i] % mod;
ans = 1ll * ans * T2.query(l, r, 1, 1, n) % mod; printf("%d\n", ans); } else { ll l = read(), r = read(), x = read(); ll st = 0; for (ll j = 0; j <= cnt; j++) if (x % p[j] == 0) st |= 1ll << j; T1.update(l, r, st, 1, 1, n); T2.update(l, r, x, 1, 1, n); } } }