while l = gets.to_i
  break if l.zero?
  savings = 0
  months = 0
  flag = false

  12.times do |month|
    m, n = gets.split.map(&:to_i)
    savings += (m-n)
    if l <= savings && !flag
      months = month+1
      flag = true
    end
  end

  puts flag ? months : "NA"
end