#encoding:utf-8 No.0206 2014.11.10
while true
  trip_expense = gets.chomp.to_i
  if trip_expense == 0
    break
  end

  money = []
  12.times do |i|
    money[i] = gets.chomp.split.map{|n| n.to_i}
  end

  term = 0
  savings = 0
  while true
    if term <= 11
      savings += money[term][0] - money[term][1]
      if savings >= trip_expense
        puts term + 1
        break
      end
      term += 1
    else
      puts "NA"
      break
    end
  end
end