from math import sqrt for _ in range(int(input())): n = int(input()) print('P' if sqrt(n) == int(sqrt(n)) else 'K')