h,w=map(int,input().split());s=[input()for _ in range(h)];y,x=0,0 for i in s: if "R"in i:y,x=s.index(i),i.index("R");break while s[(y+1)%h][(x+1)%w]!="#":y=(y+1)%h;x=(x+1)%w;exec("exit(print('loop'))"*(s[y][x]=="R")) print(y%h+1,x%w+1)