I=input
for t in [0]*int(I()):
	I()
	D={'K':0,'P':0}
	for s in I().split('-'):
		if s:D[s[0]]+=s[0]==s[-1]
	print("KP"[D['P']>D['K']])