#include #include #include using namespace std; int N,K; vectorG[2<<17]; int A[2<<17]; int dfs(int u,int p,int d) { int ret=0; if(d%2==1)ret^=A[u]%(K+1); for(int v:G[u])if(v!=p)ret^=dfs(v,u,d+1); return ret; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T;cin>>T; for(;T--;) { cin>>N>>K; for(int i=0;i>u>>v; u--,v--; G[u].push_back(v); G[v].push_back(u); } for(int i=0;i>A[i]; cout<<(dfs(0,-1,0)?"K\n":"P\n"); } }