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