import sys input = sys.stdin.readline x=3030300 Primelist=[i for i in range(x+1)] Primelist[1]=0 # 1は素数でないので0にする. for i in Primelist: if i*i>x: break if i==0: continue for j in range(2*i,x+1,i): Primelist[j]=0 for i in range(x+1): if Primelist[i]!=0: Primelist[i]=1 for i in range(1,x+1): Primelist[i]+=Primelist[i-1] T=int(input()) for tests in range(T): N=int(input()) if Primelist[N]!=0: print("P") continue ANS=N-1-(Primelist[N-1]-Primelist[N//2]) if ANS%2!=0: print("P") else: print("K")