#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" using u128 = long long; #else #define dump(...) using u128 = __uint128_t; #endif //#define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = 1'000'000'007; template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } // 累乗 // O(log e) // mod^2 が T の最大値より大きければオーバーフローするので掛け算に modmul を使う template T modpow(T a, T e, T mod) { T res = 1; while (e > 0) { if (e & 1)res = res * a % mod; // modmul(res, a, mod); a = a * a % mod; // modmul(a, a, mod); e >>= 1; } return res; } // 素数判定(Miller-Rabin primality test) // 2^24程度から // millerRabinPrimalityTest(n, 5) // modmul は遅いので極力使わない __uint128_t や BigInt を使う // Verified: https://yukicoder.me/submissions/335299 //using u128 = __uint128_t; template bool millerRabinPrimalityTest(T n, int iteration = 5) { if (n < 2)return false; if (n == 2)return true; if (n % 2 == 0)return false; T d = n - 1; while (d % 2 == 0)d /= 2; for (int i = 0; i < iteration; i++) { T a = rand() % (n - 1) + 1, t = d; T mod = modpow(a, t, n); while (t != n - 1 && mod != 1 && mod != n - 1) { mod = mod * mod % n; //modmul(mod, mod, n); t *= 2; } if (mod != n - 1 && t % 2 == 0)return false; } return true; } template bool isPrimePower(T n, int iteration = 5) { dump(n); int t = n, R = 0; while (t) { R++; t >>= 1; } dump(R); for (int r = 1; r <= R; r++) { dump(r); auto f = [&](int x) { int k = r; T y = 1; while (k) { if (y * x > n)return true; // オーバーフロー対策 if (k & 1) y *= x; x *= x; k >>= 1; } return y >= n; }; auto binarySearch = [&](T ng, T ok) { if (f(ng))return ng; while (ng + 1 < ok) { int m = (ng + ok) / 2; if (f(m)) ok = m; else ng = m; } return ok; }; auto power = [&](T a, int k) { T r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }; T p = binarySearch(T(2), n + 1); dump(p); if (power(p, r) != n)continue; if (millerRabinPrimalityTest(p, iteration)) return true; } return false; } signed main() { cin.tie(0); ios::sync_with_stdio(false); int Q; cin >> Q; rep(_, 0, Q) { long long N; cin >> N; if (N % 2 == 0) { cout << "Yes" << endl; } else { bool yes = false; rep(b, 1, 64) { long long q = 1LL << b; if (N - 3 < q)break; long long p = N - q; if (isPrimePower(u128(p))) { yes = true; break; } } if (yes) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } return 0; }