ll@h,@w,i,j,l;string@s[h];rep(k,h)l=s[k].find("R"),~l?(i=k,j=l):0;for(;++i%=h,++j%=w,s[i][j]&4;);if(s[i][j]&1)wt(i?i:h,j?j:w);else wt("loop");