#include int solve(int N, char S[]) { int i, j, num[3] = {}; for (i = 0; i < N; i = j + 1) { if (S[i] == '-') { j = i; continue; } for (j = i; j < N && S[j] != '-'; j++); j--; if (S[i] != S[j]) num[2]++; else if (S[i] == 'K') num[0]++; else num[1]++; } num[0] += (num[2] + 1) / 2; num[1] += num[2] / 2; if (num[0] >= num[1]) return 1; else return 0; } int main() { int T, N; char S[500001]; scanf("%d", &T); while (T--) { scanf("%d", &N); scanf("%s", S); if (solve(N, S) != 0) printf("K\n"); else printf("P\n"); } fflush(stdout); return 0; }