import sys input = sys.stdin.readline for i in range(int(input())): n = int(input()) s = list(input().rstrip()) def rle(s): res = [] for j in s: if not res or res[-1][0] != j: res.append([j,1]) else: res[-1][1] += 1 return res p,k = 0,0 x = rle(s) for j,z in x: if j == 'P': p += 1 if j == 'K': k += 1 if p > k: print('P') else: print('K')