from math import gcd def isprime_(n) -> bool: if n <= 1: return False if n == 2: return True if n % 2 == 0: return False s = 0 d = n-1 while d % 2 == 0: s += 1 d >>= 1 for x in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]: if x % n == 0: return True m = pow(x, d, n) if m == 1: continue t = 0 while t < s: if m == n-1: break m = m * m % n t += 1 if t == s: return False return True def pollard(n): if n % 2 == 0: return 2 if isprime_(n): return n def f(s): return (s * s + 1) % n step = 0 while True: step += 1 x = step y = f(x) while True: p = gcd(y - x + n, n) if p == 0 or p == n: break if p != 1: return p x = f(x) y = f(f(y)) def factorize(n): if n == 1: return [] p = pollard(n) if p == n: return [p] return sorted(factorize(p) + factorize(n // p)) Q = int(input()) for _ in range(Q): A = int(input()) ps = factorize(A) if len(ps) == 3: print('Yes') else: print('No')