t = int(input()) for i in range(t): n = int(input()) s = "-" + input().rstrip() d = [] for i in range(1,n+1): if s[i] == "-": continue if s[i-1] == "-": d.append([s[i]]) else: d[-1].append(s[i]) k = 0 p = 0 for i in range(len(d)): k += d[i][0] == "K" and d[i][-1] == "K" p += d[i][0] == "P" and d[i][-1] == "P" if p > k: print("P") else: print("K")