#include #include using namespace std; using namespace atcoder; int main(void){ int t; cin >> t; vector query(t); int n_max = 0; for(auto& n : query){ cin >> n; if(n_max < n){ n_max = n; } } vector rad(n_max + 1); for(int i = 2; i * i <= n_max; ++i){ if(rad[i] != 0){ continue; } for(int j = i * i; j <= n_max; j += i){ rad[j] = i; } } vector ans(n_max + 1); dsu uni(n_max + 1); for(int n = 2; n <= n_max; ++n){ if(rad[n] == 0){ ans[n] = 'P'; continue; } int x = n; while(rad[x] != 0){ int r = rad[x]; uni.merge(n, r); while(x % r == 0){ x /= r; } } if(x > 1){ uni.merge(n, x); } ans[n] = ((uni.size(n) - 1) & 1) ? 'K' : 'P'; } for(int n : query){ cout << ans[n] << endl; } return 0; }