pare=[-1]*(6*10**6+1) size=[1]*(6*10**6+1) count=[0]*(6*10**6+1) def root(x): while pare[x]!=-1: x=pare[x] return x def unite(u,v): rootu=root(u) rootv=root(v) if rootu!=rootv: if size[rootu]>=size[rootv]: pare[rootv]=rootu size[rootu]+=size[rootv] count[rootu]+=count[rootv] else: pare[rootu]=rootv size[rootv]+=size[rootu] count[rootv]+=count[rootu] def same(s,t): return root(s)==root(t) result=[0]*(3*10**6+1) used=[0]*(3*10**6+1) for x in range(2,3*10**6): if used[x]==1: continue for y in range(2,3*10**6): if x*y>3*10**6: break used[x*y]=1 z=0 for x in range(2,3*10**6+1): if used[x]==0: result[x]=1 z+=1 continue if used[x//2]==0 and x%2==0: z-=1 result[x]=(x-1)-z Q=int(input()) for _ in range(Q): N=int(input()) if result[N]%2==1: print('P') else: print('K')