c,*m=$<.to_a t=s=r=m.index{c=_1.index ?R} r,c=s,t while(x=m[s=(r+1)%m.size][t=(c+1)%(m[0].size-1)])==?. puts x==?R? :loop: "#{r+1} #{c+1}"