loop do
	h, w = gets.chomp.split.map(&:to_i)
	break if [h, w].all?(&:zero?)

	tile_map = tile_already_arrived = Array.new

	h.times do
		tile_map << gets.chomp.split('')
		tile_already_arrived << Array.new(w, false)
	end

	x = y = 0

	while true
		tile_present = tile_map[y][x]

		if tile_already_arrived[y][x] == true
			goal = "LOOP"
			break
		else
			tile_already_arrived[y][x] = true
			case tile_present
			when '>' 
				x += 1
			when '<'
				x -= 1
			when 'v'
				y += 1
			when '^'
				y -= 1
			when '.'
				goal = "#{x} #{y}"
				break
			end
		end
	end

	puts goal
end