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