for _ in range(int(input())): N = int(input()) S = input() rle = ['-'] for c in S: if rle[-1] != c: rle.append(c) if rle.count('K') >= rle.count('P'): print('K') else: print('P')