#include int solve(int N) { int i, j, k; static char flag[3000001] = {}; static int num[3000001] = {}; if (num[2] == 0) { for (i = 2; i <= 3000000; i++) { if (flag[i] != 0) continue; for (j = i * 2; j <= 3000000; j += i) flag[j] = 1; } for (i = 3, num[2] = 1; i <= 3000000; i++) { num[i] = num[i-1]; if (flag[i] == 0) num[i]++; } } if (flag[N] == 0) return 0; else if ((N - 2 - (num[N] - num[N/2])) % 2 == 0) return 0; else return 1; } int main() { int T, N; scanf("%d", &T); while (T--) { scanf("%d", &N); if (solve(N) != 0) printf("K\n"); else printf("P\n"); } fflush(stdout); return 0; }