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