def arrow(cur, arr)
  return case arr[cur[0]][cur[1]]
  when ">"
    vec_sum(cur, [0, 1])
  when "<"
    vec_sum(cur, [0, -1])
  when "^"
    vec_sum(cur, [-1, 0])
  when "v"
    vec_sum(cur, [1, 0])
  end
end

def vec_sum(v1, v2)
  return [v1[0] + v2[0], v1[1] + v2[1]]
end

loop do
  arr, path, cur = [], [], [0, 0]
  h, w = gets.split.map(&:to_i)
  
  break if h == 0 && w == 0
  
  h.times do |i|    
    arr[i] = gets.chomp.split("")
  end

  loop do
    if arr[cur[0]][cur[1]] == "."
      puts cur.reverse.join(" ")
      break
    elsif path.include?(cur)
      puts "LOOP"
      break
    end
  
    path << cur
    cur = arrow(cur, arr)
  end
end