h,w=gets.split.map(&:to_i);s=(1..h).map{gets};h.times{|y|w.times{|x|if"R"==s[y][x];loop{y=(y+1)%h;x=(x+1)%w;c=s[y][x];next if"."==c;if"R"==c;puts"loop";else;puts y>0?y:h,x>0?x:w;end;break}end}}