import sys input = sys.stdin.readline def isqrt(n): ok = 0 ng = 32 while(abs(ok - ng) > 1): mid = (ok + ng) >> 1 if(mid ** 2 <= n): ok = mid else: ng = mid return ok query = [int(input()) for _ in [0] * int(input())] for n in query: if(isqrt(n) ** 2 == n): print('P') else: print('K')