#include using namespace std; vector inp; int flip(int x){ return -abs(x+1); } pair destination(int x,int y,int dx,int dy){ int bx,by; while(inp[y][x]!='#'){ if(inp[y][x]=='0'){ bx=x; by=y; x+=dx; y+=dy; }else{ dx=flip(dx); dy=flip(dy); x+=dx; y+=dy; if(inp[y][x]=='#'){ x=bx; y=by; dx=0; dy=0; break; } } } pair sol(x-dx,y-dy); return sol; } bool DFS(int x,int y,int dx=0,int dy=0){ if(dx==0&&dy==0) return DFS(x,y,0,-1)||DFS(x,y,-1,0); pair dest=destination(x,y,dx,dy); if(x==dest.first&&y==dest.second) return false; return !DFS(dest.first,dest.second); } int main(){ freopen("note.in","r",stdin); freopen("note.out","w",stdout); ios_base::sync_with_stdio(false); int w,h; int Lx,Ly; cin>>h>>w; string S(w+1,'#'); inp.push_back(S); for(int i=0;i>c; if(c=='L'){ Lx=j+1; Ly=i+1; S.push_back('0'); } else S.push_back(c); } inp.push_back(S); } if(DFS(Lx,Ly)) cout<<'L'; else cout<<'K'; return 0; }