#include using namespace std; using ll = long long; int main(void) { int t; cin >> t; vector query(t); int m = 0; for (int i = 0; i < t; i++) { cin >> query[i]; if (m < query[i]) { m = query[i]; } } vector is_prime(m + 1, true); is_prime[0] = is_prime[1] = false; for (int i = 2; i * i <= m; i++) { if (is_prime[i] == false) { continue; } for (int j = i * i; j <= m; j += i) { is_prime[j] = false; } } vector dp(m + 1); vector ans(m + 1); for (int n = 2; n <= m; n++) { dp[n] = dp[n - 1]; if (is_prime[n]) { dp[n]++; } ans[n] = (n > 2 && (((n - 2) - dp[n] + dp[n / 2]) & 1)) ? 'K' : 'P'; } for (int n : query) { cout << ans[n] << endl; } return 0; }