T = int(input()) for _ in range(T): N = int(input()) S = list(input()) now = S[0] cnt = 1 dat = [] for i in range(1, N): if S[i] != now: dat.append([now, cnt]) cnt = 1 now = S[i] else: cnt += 1 dat.append([now, cnt]) # print(dat) cntp, cntk = 0, 0 for c, _ in dat: if c == 'P': cntp += 1 if c == 'K': cntk += 1 print("K" if cntp <= cntk else "P")