a,*s=open(0) w=len(s[0]) s="".join(s) I=s.find('R') while 1:P=I-~w;s[I:=P%len(s)-(~I%w<2)*~-w]!='.'>exit(print(*[P//w,"loop",P%w][a