#include #include using namespace std; using ll = long long; int N; string S; void solve(){ cin >> N >> S; S += '-'; int G = 0; for(int i = 0;i < N;i++){ if(S[i] == '-')continue; string t; while(S[i] != '-')t += S[i], i++; if(t.front() != t.back())continue; G += (t.front() == 'K' ? 1 : -1); } cout << (G >= 0 ? "K\n" : "P\n"); } int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while(t--)solve(); return 0; }