#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int MOD = 1000000007; using uint = unsigned int; using ll = long long; using ull = unsigned long long; constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template using V = vector; template using VV = V>; #define int long long int powi(int a, int b) { if (b == 0) { return 1; } int res = powi(a, b / 2); if (b % 2 == 0) { return res*res; } else { return res*res*a; } } struct rng { struct A { int n; const bool operator!=(A r) { return n != r.n; } A& operator++() { n++; return *this; } int operator*() { return n; } }; int l, r; rng(int r) : l(0), r(max((int)0, r)) {} rng(int l, int r) : l(l), r(max(l, r)) {} A begin() { return A{ l }; } A end() { return A{ r }; } }; template T pow(T x, ll n, T r) { while (n) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; } template T pow(T x, ll n) { return pow(x, n, T(1)); } template T pow_mod(T x, ll n, T md) { T r = 1; while (n) { if (n & 1) r = (r*x) % md; x = (x*x) % md; n >>= 1; } return r % md; } bool isPrime(ll n) { if (n <= 1) return false; if (n == 2) return true; if (n % 2 == 0) return false; ll d = n - 1; while (d % 2 == 0) d /= 2; // vector alist{2,3,1662803}; // n < 1.12e12 vector alist{ 2,3,5,7,11,13,17,19,23,29,31,37 }; // n < 2^64 for (ll a : alist) { if (n <= a) break; ll t = d; ll y = pow_mod<__int128>(a, t, n); //over while (t != n - 1 && y != 1 && y != n - 1) { y = __int128(y)*y % n; //flow t <<= 1; } if (y != n - 1 && t % 2 == 0) { return false; } } return true; } signed main() { //cerr << isPrimeMillerRabin(129, 50) << endl; cin.tie(0); ios::sync_with_stdio(false); int T; cin >> T; //T = 200; //cerr << (int)pow((int)powi(999, 6), 1/(double)1) << endl; string res; int m; int x; int aa; while (T--) { int N; cin >> N; //N = powi(MOD, 2) + powi(2, 1); //cerr << N << endl; //N = MOD; if (N % 2 == 0) { if (N == 2) { res = "No"; } else { res = "Yes"; } } else { m = 2; res = "No"; while (N - m > 1 && m > 1) { x = 1; while (x < 60) { if (x == 1) { aa = N - m; } else { aa = (int)(pow(N - m, 1 / (double)(x))); } //cerr << N - m << " " << x << " " << aa << endl; //if (aa <= 1)break; //cerr << aa << endl; for (int j = aa - 3; j < aa + 3; j++) { if (powi(j, x) == N - m) { //cerr << j << " " << x << " " << N - m << endl; if (isPrime(j)) { //cerr << m << " " << x << endl; res = "Yes"; break; } } } x++; } if (res == "Yes")break; m *= 2; } } cout << res << endl; } //cout << res << endl; }