h,w,*s=open(0).read().split();q=2e6;h=int(h);w=int(w) for c in s: if'R'in c:y=c.index('R');x=s.index(c) while q*(s[x][y]!='#'):x=(x+1)%h;y=(y+1)%w;q-=1 print(q and f"{x or h} {y or w}"or"loop")