#include using namespace std; typedef long long ll; struct sieve { vector s; sieve(int n) : s(n + 1) { for (ll i = 0; i <= n; i++) { s[i] = i; } for (ll i = 2; i <= n; i++) { if (s[i] == i) { for (ll j = i * i; j <= n; j += i) { if (s[j] == j) { s[j] = i; } } } } } vector> primeFac(int n) { vector> res; while (n != 1) { int p = s[n], cnt = 0; while (s[n] == p) { n /= p; cnt++; } res.push_back(pair(p, cnt)); } return res; } bool isPrime(int n) { if (n <= 1) return false; return (s[n] == n); } }; int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sieve s(100); int q; cin >> q; for (int qi = 0; qi < q; qi++) { int t, l, r, x; cin >> t >> l >> r >> x; l--; r--; if (t == 1) { // auto f = s.primeFac(x); for (int i = l; i <= r; i++) { a[i] = x; } } else if (t == 2) { // auto f = s.primeFac(x); for (int i = l; i <= r; i++) { a[i] *= x; } } else { ll ans = 1; for (int i = l; i <= r; i++) { if (a[i] % x == 0) { ans *= a[i]; } } cout << ans << endl; } } return 0; }