def solve(): n = int(input()) S = input() T = S.split("-") c = 0 for t in T: if t == "": continue elif t[0] == t[-1]: if t[0] == "P": c += 1 else: c -= 1 return c > 0 for _ in range(int(input())): if solve(): print("P") else: print("K")