#include #include constexpr int N = 3e6; std::vector g[N + 1]; int res[N + 1]; int main() { std::cin.tie(nullptr)->sync_with_stdio(false); for (int i = 2; i <= N; ++i) { if (!g[i].empty()) continue; for (int j = i + i; j <= N; j += i) g[j].push_back(i); } atcoder::dsu d(N + 1); for (int i = 2; i <= N; ++i) { for (auto &j : g[i]) d.merge(i, j); 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; }