ll@T;rep(T){ll@N,K=0,P=0,c=0;string@S;S+='-';rep(i,N)if(S[i]>74){if(c<75)c=S[i];if(S[i+1]<75){if(c==S[i])(c>75?P:K)++;c=0;}}wt("KP"[P>K]);}