#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; if (flag[i] == 0) { for (j = i; j <= 3000000; j += i) { if (flag[j] >= 0) { flag[j] |= 2; flag[j] ^= 1; } } if ((long long)i * i <= 3000000) for (j = i * i; j <= 3000000; j += i * i) flag[j] = -1; } for (j = i, k = 1; j <= 3000000; j += i, k++) num[j] += (flag[i] == 3)? k: -k; } } // printf("%d ", num[N]); if (num[N] % 2 == 0) return 1; else return 0; } int gcd(int a, int b) { if (a == 0) return b; else return gcd(b % a, a); } int naive(int N) { int i, num = 0; for (i = 2; i < N; i++) if (gcd(i, N) != 1) num++; // printf("%d ", num); return num % 2; } 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; }