import math
Q=int(input())
def isOk(x):
  count=0
  for i in range(2, math.floor(math.sqrt(x))+9):
    while x%i==0:
      x//=i
      count+=1
      if count>3: return 0
  if x!=1: count+=1
  return [0, 1][count==3]
for _ in range(Q):
  print(["No", "Yes"][isOk(int(input()))])