from itertools import groupby ret = [] for _ in range(int(input())): input() cs = [c for c, _ in groupby(input())] ret.append('P' if cs.count('P') > cs.count('K') else 'K') print('\n'.join(ret))