func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   const long long mod = 1e9 + 7;   int prime[500], judge[500], lcm[500][40], cnt, tol;   int tree[100][maxn << 2], root[maxn], ls[maxn << 6], rs[maxn << 6],       sum[maxn << 6], last[maxn << 1];   int a[maxn], ba = 1 << (int)ceil(log2(1e5 + 1));   inline void sieve() {     int sq = sqrt(maxn << 1);     for (int i = 2; i <= sq; i++) {       if (!judge[i]) prime[judge[i] = ++cnt] = i;       for (int j = 1, v; j <= judge[i] && (v = i * prime[j]) <= sq; j++)         judge[v] = j;     }   }   inline void build(int n, int no) {     int x, v = prime[no];     for (int i = 1; i <= n; i++) {       x = 0;       while (!(a[i] % v)) {         a[i] /= v;         x++;       }       tree[no][ba + i - 1] = x;     }     for (int i = ba - 1; i >= 1; i--)       tree[no][i] = max(tree[no][i << 1], tree[no][i << 1 | 1]);   }   inline int query(int l, int r, int no) {     l = l + ba - 1;     r = r + ba - 1;     int ans = 0;     while (l <= r) {       if (l & 1) ans = max(ans, tree[no][l++]);       if (~r & 1) ans = max(ans, tree[no][r--]);       l >>= 1;       r >>= 1;     }     return ans;   }   inline int powmod(long long a, int b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % mod;       a = a * a % mod;       b >>= 1;     }     return ans;   }   inline int buildrt(int l, int r) {     int rt = ++tol;     if (l == r) return rt;     int mid = l + r >> 1;     ls[rt] = buildrt(l, mid);     rs[rt] = buildrt(mid + 1, r);     return rt;   }   inline int updatert(int k, int l, int r, int rt, long long v) {     int now = ++tol;     ls[now] = ls[rt], rs[now] = rs[rt], sum[now] = max(sum[rt], 1) * v % mod;     if (l == r) return now;     int mid = l + r >> 1;     if (k <= mid)       ls[now] = updatert(k, l, mid, ls[now], v);     else       rs[now] = updatert(k, mid + 1, r, rs[now], v);     return now;   }   inline long long queryrt(int rt, int l, int r, int L, int R) {     if (R < l || r < L) return 1;     if (L <= l && r <= R) return max(1, sum[rt]);     int mid = l + r >> 1;     return queryrt(ls[rt], l, mid, L, R) * queryrt(rs[rt], mid + 1, r, L, R) %            mod;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     sieve();     int n, ans = 0, l, r, q;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= cnt; i++) build(n, i);     root[0] = buildrt(1, n);     for (int i = 1; i <= n; i++) {       root[i] = root[i - 1];       if (a[i] == 1) continue;       if (last[a[i]])         root[i] = updatert(last[a[i]], 1, n, root[i], powmod(a[i], mod - 2));       root[i] = updatert(i, 1, n, root[i], a[i]);       last[a[i]] = i;     }     cin >> q;     while (q--) {       cin >> l >> r;       l = (ans + l) % n + 1;       r = (ans + r) % n + 1;       if (l > r) swap(l, r);       ans = 1;       for (int i = 1; i <= cnt; i++)         ans = (long long)ans * powmod(prime[i], query(l, r, i)) % mod;       cout << (ans = ans * queryrt(root[r], 1, n, l, r) % mod) <<   n ;     }   }   