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