#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int t; cin >> t; for (; t--;) { int n; string s; cin >> n >> s; s = "-" + s + "-"; int p = 0, k = 0; for (int i = 1; i <= n; i++) { if (s[i] == '-') { continue; } if (s[i - 1] == '-' || s[i + 1] == '-') { if (s[i] == 'P') { p++; } else { k++; } } } if (p > k) { cout << "P\n"; } else { cout << "K\n"; } } }