import sys input = sys.stdin.readline T=int(input()) for tests in range(T): N=int(input()) S=input().strip() LIST=[] now=[] for s in S: if s=="-": if now!=[]: LIST.append(now) now=[] else: now+=[s] P=0 K=0 for l in LIST: if l[0]==l[-1]=="P": P+=1 elif l[0]==l[-1]=="K": K+=1 if K>P: print("K") else: print("P")