#include using namespace std; using ll = long long; using pll = pair; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); const ll MOD1000000007 = 1000000007; const ll MOD998244353 = 998244353; const ll MOD[3] = {999727999, 1070777777, 1000000007}; const ll LINF = 1LL << 60LL; const int IINF = (1 << 30) - 1; struct union_find{ vector par; vector siz; union_find(int n) : par(n), siz(n, 1){ for(int i=0; i cnt(3e6+1, 0); void solve(){ int n; cin >> n; if(cnt[n]%2==0) cout << "P\n"; else cout << "K\n"; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); union_find uf(3e6+1); vector isprime(1e4+1, true); isprime[0]=isprime[1]=false; for(int i=2; i<=1e4; i++){ if(!isprime[i]) continue; for(int j=2*i; j<=1e4; j+=i) isprime[j] = false; } vector prime; for(int i=2; i<=1e4; i++) if(isprime[i]) prime.pb(i); for(int i=2; i<=3e6; i++){ for(int p : prime){ if(p*p>i) break; if(i%p==0){ uf.unite(p, i); uf.unite(p, i/p); } } cnt[i] = uf.size(i)-1; } int T; cin >> T; while(T--) solve(); }