#include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef pair P; typedef long double ld; templateistream& operator>>(istream& is, vector& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template ostream& operator<<(ostream& os, const pair& p){os << p.first << ' ' << p.second; return os;} templateostream& operator<<(ostream& os, const vector& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const vector>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} template void chmin(T& a, T b){a = min(a, b);} template void chmax(T& a, T b){a = max(a, b);} int solve(){ int n; cin >> n; int k = 0, p = 0; string s; { string _s; cin >> _s; s += '-'; s += _s; s += '-'; n += 2; } char first = '?'; char last = '?'; rep(i, n){ if(s[i] == '-'){ if(first == '?') continue; else{ if(first == 'P' and last == 'P') p++; if(first == 'K' and last == 'K') k++; first = '?'; last = '?'; } }else{ if(first == '?') first = s[i]; last = s[i]; } } if(k >= p) cout << "K\n"; else cout << "P\n"; return 0; } int main(){ int t; cin >> t; rep(_, t) solve(); return 0; }