#include #include constexpr int N = 3e6; int main() { std::cin.tie(nullptr)->sync_with_stdio(false); int st[N + 1]{}; for (int i = 2; i * i <= N; ++i) { if (st[i]) continue; for (int j = i * i; j <= N; j += i) st[j] = i; } atcoder::dsu d(N + 1); int res[N + 1]{}; for (int i = 2; i <= N; ++i) { if (st[i]) { d.merge(i, st[i]); int x = i; while (x % st[i] == 0) x /= st[i]; if (x > 1) d.merge(i, x); } res[i] = d.size(i) & 1; } int q; std::cin >> q; while (q--) { int n; std::cin >> n; std::cout << (res[n] ? "P" : "K") << '\n'; } return 0; }