def arrow(current, tiles)
  case tiles[current[0]][current[1]]
  when ">"
    return [current[0], current[1] + 1]
  when "<"
    return [current[0], current[1] - 1]
  when "^"
    return [current[0] - 1, current[1]]
  when "v"
    return [current[0] + 1, current[1]]
  end  
  
end

while true
  tiles, path, current = [], [], [0, 0]
  h, w = gets.split.map(&:to_i)
  
  break if h == 0 && w == 0
  
  h.times do |i|    
    tiles[i] = gets.chomp.split("")
  end

  while true
    if tiles[current[0]][current[1]] == "."
      puts current.reverse.join(" ")
      break
    elsif path.include?(current)
      puts "LOOP"
      break
    end
  
    path << current
    current = arrow(current, tiles)
  end
end