def suspect(a, t, n): x = pow(a, t, n) n1 = n - 1 while t != n1 and x != 1 and x != n1: x = pow(x, 2, n) t <<= 1 return t & 1 or x == n1 # メイン # 2^64までの決定的アルゴリズムとして実装しているので、ランダム要素は無い # ランダムとして用いる場合は、check_listにランダム抽出された数を採用し、20~50個程度試す def miller_rabin(n): if n == 2: return True if n < 2 or n % 2 == 0: return False d = (n - 1) >> 1 while d & 1 == 0: d >>= 1 check_list = (2, 7, 61) if n < 2 ** 32 else (2, 325, 9375, 28178, 450775, 9780504, 1795265022) for i in check_list: if i >= n: break if not suspect(i, d, n): return False return True def prime_factorize(n): a = [] cnt=0 while n % 2 == 0 and cnt<2: a.append(2) n //= 2 cnt+=1 f = 3 while f * f <= n and cnt<2: if n % f == 0: a.append(f) n //= f cnt+=1 else: f += 2 return a q = int(input()) for _ in range(q): n = int(input()) l = prime_factorize(n) # print(l,len(l)) if len(l)==2: if miller_rabin(n//(l[0]*l[-1])): print('Yes') else: print('No')