s,*m=$<.to_a h,w=s.split.map &:to_i s=r=(0..t=c=h).find{c=m[_1].index ?R} r,c=s,t while m[s=(r+1)%h][t=(c+1)%w]==?. puts m[s][t]==?R? :loop: "#{r+1} #{c+1}"