# WA? import sys input = sys.stdin.readline query = [int(input()) for _ in [0] * int(input())] for n in query: if((n ** 0.5) ** 2 == n): print('P') else: print('K')