loop{
	h,w=gets.chomp.split(" ").map{|i| i.to_i}
	break if h==0 && w==0
	map=Array.new(h,Array.new(w))
	pos=Array.new[0,0]

	for i in 0..h-1
		map[i]=gets.chomp.split("").map{|i|i.to_s}
	end

	x=0
	y=0
	loop{
		case map[y][x]
		when ">"
			x+=1
		when "<"
			x-=1
		when "^"
			y-=1
		when "v"
			y+=1
		when "."
			puts "#{x} #{y}"
			break
		end
		pos << [x,y]
		if 	pos.size != pos.uniq.size
			puts "LOOP"
			break
		end
	}
}