#include #include using namespace std; using namespace atcoder; //const long long INF = 1LL<<60; int main() { int t; cin >> t; for (int i=0; i < t; i++){ long long n; cin >> n; if (n == (sqrtl(n) * sqrtl(n))) cout << "P" << endl; else cout << "K" << endl; } return 0; }