try:
n = int(input())
conf_prim=[]
nmb_conf_prim=[]
for a in range(0,n):
nmb_conf_prim.append(0)
x = int(input())
if x==2:
conf_prim.append("TAK")
elif x==1:
conf_prim.append("NIE")
elif x%2==0 and x!=2:
conf_prim.append("NIE")
elif x%3==0 and x!=3:
conf_prim.append("NIE")
elif x%5==0 and x!=5:
conf_prim.append("NIE")
elif x%7==0 and x!=7:
conf_prim.append("NIE")
else:
for b in range(1, 4999):
if x % b == 0:
nmb_conf_prim[a] += 1
if nmb_conf_prim[a]>2:
conf_prim.append("NIE")
break
if nmb_conf_prim[a] <= 2:
conf_prim.append("TAK")
for c in range(0,n):
print(conf_prim[c])
except(EOFError):
print("CJUK")
dHJ5OgogICAgbiA9IGludChpbnB1dCgpKQogICAgY29uZl9wcmltPVtdCiAgICBubWJfY29uZl9wcmltPVtdCgoKICAgIGZvciBhIGluIHJhbmdlKDAsbik6CiAgICAgICAgbm1iX2NvbmZfcHJpbS5hcHBlbmQoMCkKICAgICAgICB4ID0gaW50KGlucHV0KCkpCiAgICAgICAgaWYgeD09MjoKICAgICAgICAgICAgY29uZl9wcmltLmFwcGVuZCgiVEFLIikKICAgICAgICBlbGlmIHg9PTE6CiAgICAgICAgICAgIGNvbmZfcHJpbS5hcHBlbmQoIk5JRSIpCiAgICAgICAgZWxpZiB4JTI9PTAgYW5kIHghPTI6CiAgICAgICAgICAgIGNvbmZfcHJpbS5hcHBlbmQoIk5JRSIpCiAgICAgICAgZWxpZiB4JTM9PTAgYW5kIHghPTM6CiAgICAgICAgICAgIGNvbmZfcHJpbS5hcHBlbmQoIk5JRSIpCiAgICAgICAgZWxpZiB4JTU9PTAgYW5kIHghPTU6CiAgICAgICAgICAgIGNvbmZfcHJpbS5hcHBlbmQoIk5JRSIpCiAgICAgICAgZWxpZiB4JTc9PTAgYW5kIHghPTc6CiAgICAgICAgICAgIGNvbmZfcHJpbS5hcHBlbmQoIk5JRSIpCiAgICAgICAgZWxzZToKICAgICAgICAgICAgZm9yIGIgaW4gcmFuZ2UoMSwgNDk5OSk6CiAgICAgICAgICAgICAgICBpZiB4ICUgYiA9PSAwOgoKICAgICAgICAgICAgICAgICAgICBubWJfY29uZl9wcmltW2FdICs9IDEKICAgICAgICAgICAgICAgICAgICBpZiBubWJfY29uZl9wcmltW2FdPjI6CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZfcHJpbS5hcHBlbmQoIk5JRSIpCiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrCiAgICAgICAgICAgIGlmIG5tYl9jb25mX3ByaW1bYV0gPD0gMjoKICAgICAgICAgICAgICAgIGNvbmZfcHJpbS5hcHBlbmQoIlRBSyIpCgoKICAgIGZvciBjIGluIHJhbmdlKDAsbik6CiAgICAgICAgcHJpbnQoY29uZl9wcmltW2NdKQoKZXhjZXB0KEVPRkVycm9yKToKICAgIHByaW50KCJDSlVLIik=