#include #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; template T pow_mod(T a, T n, T m) { T res = 1%m; a %= m; while (n) { if (n&1) res = res*a%m; a = a*a%m; n >>= 1; } return res; } bool isPrime(ll n) { if (n <= 1) return false; if (n == 2) return true; if (n%2 == 0) return false; vector a = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; int s = 0; ll d = n-1; while (d%2 == 0) { ++s; d >>= 1; } for (ll x : a) { if (x >= n) break; ll b = pow_mod<__int128_t>(x, d, n); if (b != 1) { bool ok = true; rep(i, s) { if (b == n-1) { ok = false; break; } b = __int128_t(b)*b%n; } if (ok) return false; } } return true; } ll gcd(ll a, ll b) { a = abs(a), b = abs(b); if (b == 0) return a; return gcd(b, a%b); } ll pollard(ll n) { if (n%2 == 0) return 2; if (isPrime(n)) return n; auto f = [&](ll x) -> ll { return (__int128_t(x)*x+1)%n; }; ll step = 0; while (1) { ++step; ll x = step, y = f(x); while (1) { ll p = gcd(y-x+n, n); if (!p or p == n) break; if (p != 1) return p; x = f(x); y = f(f(y)); } } } vector fatorList(ll n) { if (n == 1) return {}; ll p = pollard(n); if (p == n) return {p}; vector left = fatorList(p); vector right = fatorList(n/p); left.insert(left.end(), right.begin(), right.end()); sort(left.begin(), left.end()); return left; } void solve() { ll n; cin >> n; if (n == 1) { puts("No"); return; } auto fs = fatorList(n); if ((int)fs.size() == 3) puts("Yes"); else puts("No"); } int main() { int t; cin >> t; while (t--) solve(); return 0; }