until (a = $<.gets.split.map(&:to_i)) == [0, 0]
  h, w = a
  tiles = h.times.map {$<.gets.chomp}
  positions = [0]
  x, y = 0, 0
  
  result = loop do
    case tiles[y][x]
    when ">" then x += 1
    when "<" then x -= 1
    when "^" then y -= 1
    when "v" then y += 1
    when "." then break "#{x} #{y}"
    else raise "error"
    end
    po = y * w + x
    break "LOOP" if positions.include?(po)
    positions << po
  end
  puts result
end

