h,*t=open(0) h,w=map(int,h.split()) for i in range(h): if 'R'in t[i]:p,q=i,t[i].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}')