P=[i*i for i in range(32)] T=int(input()) for t in range(T): n=int(input()) print('P' if n in P else 'K')