while true
    l = gets.to_i
    break if l == 0
    sum, count = 0, "NA"
    12.times{|i|
        m, n = gets.chomp.split.map(&:to_i)
        sum += m - n
        count = i + 1 if sum >= l && count == "NA"
    }
    puts count
end
