for _ in range(int(input())): if int(input()) in [i*i for i in range(32)]: print("P") else: print("K")