#include #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template constexpr T INF = numeric_limits::max() / 100; mt19937 mt{random_device{}()}; ll power(const ll p, const ll n, const ll mod) { if (n == 0) { return 1; } if (n % 2 == 1) { return (ll)((__int128_t)((__int128_t)power(p, n - 1, mod) * (__int128_t)p) % mod); } else { const __int128_t pp = power(p, n / 2, mod); return (ll)((__int128_t)(pp * pp) % mod); } } bool isPrime(const ll n) { constexpr int TEST = 1000; ll s = 0; ll d = n - 1; while (d % 2 == 0) { s++; d /= 2; } uniform_int_distribution dist{1, n - 1}; for (int i = 0; i < TEST; i++) { const ll a = dist(mt); if (power(a, n - 1, n) != 1) { return false; } ll num = power(a, d, n); if (num != 1) { bool comp = true; for (ll r = 0; r < s; r++) { if (num == n - 1) { comp = false; break; } num = (ll)((__int128_t)((__int128_t)num * (__int128_t)num) % n); } if (comp) { return false; } } } return true; } int main() { cin.tie(0); ios::sync_with_stdio(false); int Q; cin >> Q; for (int q = 0; q < Q; q++) { ll N; cin >> N; if (N == 1) { show(N); cout << "No" << endl; } else if (N == 2) { show(N); cout << "No" << endl; } else if (N % 2 == 0) { cout << "Yes" << endl; } else { bool ok = false; for (int i = 1; (1LL << i) < N; i++) { if (ok) { break; } const ll res = N - (1LL << i); for (int j = 1; j <= (int)log2(res * 2 - 1); j++) { if (ok) { break; } const ll rt = (ll)pow(res, 1.0 / j) + 1; if (power(rt, j, (ll)1e18) == res) { if (isPrime(rt)) { ok = true; break; } } else if (power(rt - 1, j, (ll)1e18) == res) { if (isPrime(rt - 1)) { ok = true; break; } } } } if (ok) { cout << "Yes" << endl; } else { show(N); cout << "No" << endl; } } } return 0; }