#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); const int M = 3000000; vector is_p(M + 1, true); for (int i = 2; i <= M; i++) { if (is_p[i]) { for (int j = 2 * i; j <= M; j += i) { is_p[j] = false; } } } vector p_cum(M + 1); for (int i = 1; i <= M; i++) { p_cum[i] = p_cum[i - 1] + is_p[i]; } int t; cin >> t; for (; t--;) { int n; cin >> n; if (is_p[n]) { cout << "P\n"; continue; } int cnt = n - 1 - (p_cum[n] - p_cum[n / 2]); if (cnt % 2) { cout << "P\n"; } else { cout << "K\n"; } } }