while true do
  n = gets.chomp.to_i
  break if n == 0
  array = []
  n.times do
    ar = gets.chomp.split(" ").map(&:to_i)
    ar << ar[1] * ar[2]
    index = array.index{|arr| arr.first == ar.first}
    if index.nil?
      array << ar
    else
      array[index][1] += ar[1]
      array[index][2] += ar[2]
      array[index][3] += ar[3]
  end
  numbers = array.select{|ar| ar[3] >= 1000000}.map(&:first)
  if numbers.length > 0
    numbers.each do |number|
      puts number.to_s
    end
  else
    puts "NA"
  end
end