#include #include constexpr int N = 3e6; std::vector g[N + 1]; int main() { std::cin.tie(nullptr)->sync_with_stdio(false); for (int i = 2; i * i <= N; ++i) { if (!g[i].empty()) continue; for (int j = i + i; j <= N; j += i) g[j].push_back(i); } int q; std::cin >> q; std::vector queries(q), ord(q), res(q); for (auto &x : queries) std::cin >> x; std::iota(ord.begin(), ord.end(), 0); std::ranges::sort(ord, {}, [&](int i) {return queries[i];}); int u = 2; atcoder::dsu d(N + 1); for (auto &i : ord) { int n = queries[i]; while (u <= n) { for (auto &v : g[u]) d.merge(u, v); u += 1; } res[i] = d.size(n) & 1; } for (auto &x : res) std::cout << (x ? "P" : "K") << '\n'; return 0; }