while true
    h, w = gets.chomp.split.map(&:to_i)
    break if [h, w] == [0, 0]
    map = []
    h.times{map << gets.chomp}
    x = y = 0
    hash = {}
    loop = false
    while true
        if hash[[x, y]]
            loop = true
            break
        end
        hash[[x, y]] = true
        case map[y][x]
        when '>' then x += 1
        when '<' then x -= 1
        when '^' then y -= 1 
        when 'v' then y += 1
        when '.' then break
        end
    end
    puts loop ? "LOOP" : "#{x} #{y}"
end

