#include int main () { int t = 0; int n = 0; char s[500001] = ""; int res = 0; res = scanf("%d", &t); while (t > 0) { int cnt[2] = {}; res = scanf("%d", &n); res = scanf("%s", s); for (int i = 0; i < n; i++) { if (s[i] == 'P' && (i <= 0 || s[i-1] == '-')) { cnt[0]++; } else if (s[i] == 'K' && (i <= 0 || s[i-1] == '-')) { cnt[1]++; } if (s[i] == 'P' && (i >= n-1 || s[i+1] == '-')) { cnt[0]++; } else if (s[i] == 'K' && (i >= n-1 || s[i+1] == '-')) { cnt[1]++; } } if (cnt[0] > cnt[1]) { printf("P\n"); } else { printf("K\n"); } t--; } return 0; }