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