THD = 1000000

while true
  n = gets.chomp.to_i
  break if n == 0

  totals = {}
  totals.default = 0
  ids = {}

  n.times do
    i, p, q = gets.chomp.split(" ").map{|s| s.to_i}

    ts = p * q
    t = (totals[i] += ts)
    if t >= THD && ids[i].nil?
      puts i
      ids[i] = 1
    end
  end

  puts "NA" if ids.empty?
end