import sys input = sys.stdin.readline query = [int(input()) for _ in [0] * int(input())] n_max = max(query) is_prime = [True] * (n_max + 1) is_prime[0] = is_prime[1] = False for i in range(2, int(n_max ** 0.5 + 2)): if not(is_prime[i]): continue for j in range(i * i, n_max + 1, i): is_prime[j] = False dp = [0] * (n_max + 1) ans = [''] * (n_max + 1) for n in range(2, n_max + 1): dp[n] = dp[n - 1] if(is_prime[n]): dp[n] += 1 ans[n] = 'P' continue ans[n] = 'K' if(((n - 2) - dp[n] + dp[n >> 1]) & 1) else 'P' for n in query: print(ans[n])