import math for i in range(int(input())): x = int(input()) if math.isqrt(x)**2 == x: print('P') else: print('K')