#include class UnionFind { private: int n; std::vector dsu; public: UnionFind(int n = 0) : n(n), dsu(n, -1) {} int find(int x) { if (dsu[x] < 0) return x; return dsu[x] = find(dsu[x]); } int unite(int x, int y) { x = find(x), y = find(y); if (x == y) return x; if (dsu[x] > dsu[y]) std::swap(x, y); dsu[x] += dsu[y]; dsu[y] = x; return x; } bool same(int x, int y) { return find(x) == find(y); } int size(int x) { return -dsu[find(x)]; } }; 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; } UnionFind d(N + 1); int res[N + 1]{}; for (int i = 2; i <= N; ++i) { if (st[i]) { d.unite(i, st[i]); int x = i; while (x % st[i] == 0) x /= st[i]; if (x > 1) d.unite(i, x); } res[i] = d.size(i) & 1; // res[i] = d.size(i); } int q; std::cin >> q; while (q--) { int n; std::cin >> n; // std::cout << res[n] << '\n'; std::cout << (res[n] ? "P" : "K") << '\n'; } return 0; }