#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace atcoder; #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) #define all(...) std::begin(__VA_ARGS__), std::end(__VA_ARGS__) #define rall(...) std::rbegin(__VA_ARGS__), std::rend(__VA_ARGS__) #define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i) #define REV(i, a, b) for (int i = (a); i >= (b); --i) #define CLR(a, b) memset((a), (b), sizeof(a)) #define DUMP(x) cout << #x << " = " << (x) << endl; #define INF 1001001001001001001ll #define inf (int)1001001000 #define MOD 998244353 #define Dval 1e-12 #define fcout cout << fixed << setprecision(12) #define mp make_pair #define pb push_back #define fi first #define se second using ll = long long; using vi = vector; using vl = vector; using vs = vector; using vd = vector; using vc = vector; using vb = vector; using vpii = vector>; using vpll = vector>; using vvi = vector>; using vvl = vector>; using vvd = vector>; using vvc = vector>; using vvb = vector>; using vvvi = vector>>; using pii = pair; using pll = pair; using mint = atcoder::modint998244353; ll POW(ll x, ll n){ll ret=1; while(n>0){ if(n&1) ret=ret*x; x=x*x; n>>=1; } return ret;} ll modpow(ll a, ll n, ll p) { if(n==0) return (ll)1; if (n == 1) return a % p; if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p; ll t = modpow(a, n / 2, p); return (t * t) % p;} ll modinv(ll a, ll m) { if(m==0)return (ll)1; ll b = m, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;} const int MAXCOMB=510000; ll MODCOMB = 998244353; ll fac[MAXCOMB], finv[MAXCOMB], inv[MAXCOMB]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAXCOMB; i++) { fac[i] = fac[i - 1] * i % MODCOMB; inv[i] = MODCOMB - inv[MODCOMB%i] * (MODCOMB / i) % MODCOMB; finv[i] = finv[i - 1] * inv[i] % MODCOMB; }} ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MODCOMB) % MODCOMB;} ll com(ll n,ll m){ if(n inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false));} template inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false));} void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); } void yes() { cout << "Yes\n"; exit(0); } template void er(T a) { cout << a << '\n'; exit(0); } int dx[] = { 1,0,-1,0,1,1,-1,-1,0 }; int dy[] = { 0,1,0,-1,1,-1,1,-1,0 }; long long SQUARE_MOD(ll n, ll m){ if(n == 0) return 0; ll sum = 0; ll mul = n; ll pow9 = 0; while(mul > 0){ ll val = 0; val = n * (mul % 9); val %= m; for(int i = 0; i < pow9; i++){ val *= 9; val %= m; } sum += val; sum %= m; mul /= 9; pow9++; } return sum; } //intを超えた2数のmod積の計算(n,m <= 10^18) long long MULTIPLY(ll n, ll m, ll mod){ if(n == 0 || m == 0) return 0; ll sum = 0; ll mul = m; ll pow9 = 0; while(mul > 0){ ll val = 0; val = n * (mul % 9); val %= mod; for(int i = 0; i < pow9; i++){ val *= 9; val %= mod; } sum += val; sum %= mod; mul /= 9; pow9++; } return sum; } long long POW_MOD(ll a, ll n, ll m){ if(n == 0) return 1; if(a == 0) return 0; ll sum = 1; ll val = a; while(n > 0){ if(n & 1){ sum = MULTIPLY(sum, val, m); } val = SQUARE_MOD(val, m); n >>= 1; } return sum; } bool Mirror_Rebin(ll n){ if(n == 2) return true; if(n % 2 == 0) return false; bool comp = false; ll m = n; m--; ll rad = 0; while(m % 2 == 0){ rad++; m /= 2; } //vector vec = {2, 13, 23, 1662803}; //nがintの範囲ならこれで十分 vector vec = {2,3,5,7,11,13,17,19,23,29,31,37}; //nが64bit用 for(auto g: vec){ if(n == g) return true; } for(int i = 0; i < vec.size(); i++){ ll a = vec[i]; ll val = POW_MOD(a,m,n); if(val == 1) continue; bool fin = false; for(int j = 0; j < rad; j++){ if(val == n-1){ fin = true; continue; } val = POW_MOD(val,2,n); } if(!fin) return false; } return true; } ll proot(ll n, ll m){ ll root = (ll)round(pow(n, 1.0/m)); if((ll)round(pow(root, m)) == n) return root; else return -1; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int q; cin>>q; while(q--){ ll n; cin>>n; if(n<=3){ cout<<"No"<=2){ ll m=n-pow2; if(m==1)break; for(ll i=64;i>=1;i--){ ll r=proot(m,i); if(r==-1)continue; if(r==1)continue; if(Mirror_Rebin(r)) yes=1; break; } pow2*=2; } if(yes)cout<<"Yes"<