voidwork() { static std::mt19937 rnd(std::random_device{}()); int mul = ((int) 1e9 + 8) / 3; for (int i = 0, t; i < cnt; ++ i) { while (std::__gcd(t = rnd() % (Mod - 1), Mod - 1) != 1); rv[i] = qpow(13, (LL) mul * t % (Mod - 1)); } pre[0] = 1; for (int i = 1, x, p, id; i <= n; ++ i) { x = a[i], pre[i] = pre[i - 1]; while (x ^ 1) { p = mxp[x]; id = std::lower_bound(prime, prime + cnt, p) - prime; while (x % p == 0) pre[i] = (LL) pre[i] * rv[id] % Mod, x /= p; } } for (int i = 1; i <= Q; ++ i) res[i] &= (LL) pre[q[i].r] * qpow(pre[q[i].l - 1]) % Mod == 1; }
intmain() { sieve(); std::cin >> n >> Q; for (int i = 1; i <= n; ++ i) scanf("%d", a + i); for (int i = 1; i <= Q; ++ i) res[i] = true; for (int i = 1; i <= Q; ++ i) scanf("%d %d", &q[i].l, &q[i].r); int T = 20; while (T --) work(); for (int i = 1; i <= Q; ++ i) puts(res[i] ? "Yes" : "No"); return0; }