p=[2]
o=p[-1]
while o<=(int(65535**(1/2))):
flag=True
for i in p:
if o%i==0:
flag=False
break
if flag:
p.append(o)
o+=1
n=int(input())
for i in range(n):
N=int(input())
if N in p:
print("Y")
continue
ip=True
for i in p:
if i**2>N:
break
if N%i==0:
ip=False
break
if ip:
print("Y")
else:
print("N")