import sys input = sys.stdin.readline class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if(self.parents[x] < 0): return x self.parents[x] = self.find(self.parents[x]) return self.parents[x] def unite(self, x, y): x = self.find(x) y = self.find(y) if(x == y): return if(self.parents[x] > self.parents[y]): x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def same(self, x, y): return self.find(x) == self.find(y) def size(self, x): return -self.parents[self.find(x)] def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] """ Main Code """ query = [int(input()) for _ in [0] * int(input())] n_max = max(query) rad = [0] * (n_max + 1) for i in range(2, int(n_max ** 0.5 + 2)): if(rad[i] != 0): continue for j in range(i * i, n_max + 1, i): rad[j] = i uni = UnionFind(n_max + 1) ans = [''] * (n_max + 1) for n in range(2, n_max + 1): if(rad[n] == 0): ans[n] = 'P' continue x = n while(rad[x] != 0): r = rad[x] uni.unite(n, r) while(x % r == 0): x //= r if(x > 1): uni.unite(n, x) ans[n] = 'K' if((uni.size(n) - 1) & 1) else 'P' for n in query: print(ans[n])