#include using namespace std; void solve(){ int n; cin >> n; string S; cin >> S; int num = 0; int now = 0; while (now < n){ if (S[now] == '-'){ now++; continue; } char sta = S[now]; while (now < n && S[now] != '-'){ now++; } char en = S[now-1]; if (sta != en) continue; if (sta == 'P'){ num++; } else{ num--; } } if (num > 0){ cout << "P" << endl; } else{ cout << "K" << endl; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; for (int i = 0; i < t; i++){ solve(); } return 0; }