def run_length_encoding(A): B = [] for a in A: if B and B[-1][0] == a: B[-1][1] += 1 else: B.append([a, 1]) return B for _ in range(T := int(input())): N = int(input()) S = input() T = run_length_encoding(S) K = P = 0 for c, l in T: if c == 'K': K += 1 elif c == 'P': P += 1 print('K' if K >= P else 'P')