import math for _ in range(int(input())): N=int(input()) Ncopy = N isLosenum = 2 for i in range(2,N): isLosenum = True while N%i == 0: isLosenum = False N //= i if isLosenum: LoseNum = i break if math.gcd(Ncopy,LoseNum) != 1: print("P") else: print("K")