loop do
	w, h = gets.chomp.split.map(&:to_i)
	break if [w, h].all?(&:zero?)
	tile_map = Array.new
	h.times do |i|
		tile_map[i] = gets.chomp.split('')	
	end

	x = y = 0
	tile_already_arrived = Array.new
	h.times { tile_already_arrived << Array.new(w, false) }
	is_loop = false

	while true
		tile = tile_map[y][x]
		if tile_already_arrived[y][x] == true
			is_loop = true
			break
		else
			tile_already_arrived[y][x] = true
			case tile
			when '>' 
				x += 1
			when '<'
				x -= 1
			when 'v'
				y += 1
			when '^'
				y -= 1
			when '.'
				goal = [x,y]
				break
			end
		end
	end

	if is_loop
		puts "LOOP"
	else
		puts "#{goal[0]} #{goal[1]}"
	end
end