require 'set'
d_map = {'<' => [-1, 0], '>' => [1, 0], '^' => [0, -1], 'v' => [0, 1]}
until (h_w = gets.split(' ').map(&:to_i)) == [0, 0]
  h = h_w.first
  f = h.times.map { gets.chomp.each_char.map {|c| d_map[c] } }
  xy = [0, 0]
  visited = Set.new
  loop do
    if visited.include? xy
      puts 'LOOP'
      break
    end

    visited << xy
    d = f[xy[1]][xy[0]]

    if d.nil?
      puts xy.join(' ')
      break
    end

    xy = [xy[0] + d[0], xy[1] + d[1]]
  end
end