T = int(input()) for _ in range(T): N = int(input()) S = input() K = 0 P = 0 d = 0 left = 0 right = 0 for i in range(len(S)): if i == 0 and S[i] != "-" or i >= 1 and S[i-1] == "-" and S[i] != "-": if S[i] == "K": left = 0 else: left = 1 if i >= 1 and S[i-1] != "-" and S[i] == "-": if S[i-1] == "K": right = 0 else: right = 1 if left == right: if left == 0: K += 1 else: P += 1 else: if d == 0: K += 1 else: P += 1 d ^= 1 if S[-1] != "-": if S[-1] == "K": right = 0 else: right = 1 if left == right: if left == 0: K += 1 else: P += 1 else: if d == 0: K += 1 else: P += 1 if K >= P: print("K") else: print("P")