class NextTrip
  def solve
    while true
      target_price = gets.to_i
      break if target_price <= 0
      calc(target_price)
    end
  end

  private
  def calc(target_price)
    answer = 'NA'
    1.upto(12) do |month|
      m, n = gets.split.map(&:to_i)
      target_price -= (m - n)
      if target_price <= 0 && answer == 'NA'
        answer = month
      end
    end
    puts answer
  end
end

next_trip = NextTrip.new
next_trip.solve