#include using namespace std; template T modpow(T a, T b, T mod) { T cur = a, res = 1; while (b) { if (b & 1) { res = (res * cur) % mod; } cur = (cur * cur) % mod; b >>= 1; } return res; } bool MillerRabin(long long n) { if (n <= 1) { return false; } if (n == 2 || n == 7 || n == 61) { return true; } if (n % 2 == 0) { return false; } vector A; if (n < 4759123141) { A = {2, 7, 61}; } else { A = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; } long long s = 0, d = n - 1; while (d % 2 == 0) { s++; d >>= 1; } for (auto a : A) { if (n <= a) { return true; } long long x = modpow<__int128_t>(a, d, n); if (x == 1) { continue; } bool ok = false; for (int i = 0; i < s; i++) { if (x == n - 1) { ok = true; break; } x = (__int128_t)x * x % n; } if (!ok) { return false; } } return true; } long long gcd(long long x, long long y) { if (y == 0) { return x; } return gcd(y, x % y); } unsigned int xorshift() { static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123; unsigned int t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } long long Pollard(long long n) { if (n % 2 == 0) { return 2LL; } if (MillerRabin(n)) { return n; } long long i = 0; while (true) { long long r = xorshift(); auto f = [&](auto f, long long x) -> long long { return (__int128_t(x) * x + r) % n; }; i++; long long x = i, y = f(f, x); while (true) { long long p = gcd(y - x + n, n); if (p == 0 || p == n) { break; } if (p != 1) { return p; } x = f(f, x); y = f(f, f(f, y)); } } } map mp; int prime_factorize(long long n) { if (n == 1) { return 0; } long long p = Pollard(n); if (p == n) { return mp[n] = 1; } if (mp[n] > 0) { return mp[n]; } int l = prime_factorize(p); int r = prime_factorize(n / p); int res = l + r; return mp[n] = res; } int main() { int q; cin >> q; while (q--) { long long a; cin >> a; cout << (prime_factorize(a) == 3 ? "Yes" : "No") << endl; } }