Q=int(input()) def prime_factorize(n): a = [] while n % 2 == 0: n //= 2; a.append(2) f = 3 while f * f <= n: if n % f == 0: n //= f; a.append(f) else: f += 2 if n != 1: a.append(n) return a for _ in range(Q): A=int(input()) f=prime_factorize(A) if len(f)==3:print("Yes") else:print("No")