from math import isqrt for _ in range(int(input())): N = int(input()) print('P' if isqrt(N) ** 2 == N else 'K')