t=int(input()) for _ in range(t): n=int(input()) sq_n=int(n**0.5) if sq_n*sq_n==n: print('P') else: print('K')