h,*t=open(i:=0) h,w=map(int,h.split()) for s in t: ++i if'R'in s:p,q=i,s.index('R') while t[p:=(p+1)%h][q:=(q+1)%w]=='.':() print('loop'if t[p][q]=='R'else f'{p if p>0 else h} {q if q>0 else w}')