//Date: 2025-07-27 14:32:02 #include using namespace std; #define int long long #define P emplace_back #define CLEAR(a, v) memset(a, (v), sizeof(a)) #define pii pair #define fi first #define se second #define rep(i, a, b) for(int i = (a); i <= (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) //char buf[1 << 20], *p1, *p2; //#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++) inline int rd() { int s = 0, m = 0; char ch = getchar(); while(!isdigit(ch)) {if(ch == '-') m = 1; ch = getchar();} while(isdigit(ch)) s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar(); return m ? -s : s; } bool MBE; namespace SOLVER { int n, x, y; void MAIN() { n = rd(), x = y = 0; if(n == 2) return puts("P"), void(); for(int i = 2; i <= n && (!x || !y); i++) { if(!x && __gcd(i, n) == 1) x = i; if(!y && n % i) y = i; } if(!x) puts("P"); else puts(x > y ? "P" : "K"); } } bool MED; signed main() { // freopen(".in", "r", stdin); freopen(".out", "w", stdout); // cin.tie(0), cout.tie(0), ios::sync_with_stdio(0); for(int tt = rd(); tt; tt--) SOLVER::MAIN(); cerr << (&MBE - &MED) / 1024 << " KB, " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n"; return 0; }