T = int(input()) for _ in range(T): N = int(input()) S = input().rstrip() D = [] k = S[0] cnt = 1 for i in range(1, len(S)): if S[i] == k: cnt += 1 else: D.append((k, cnt)) k = S[i] cnt = 1 D.append((k, cnt)) K, P = 0, 0 for k, cnt in D: if k == "K": K += 1 elif k == "P": P += 1 print("K" if K >= P else "P")