#coding: utf-8
#AOJ vol1-0100

while (n = gets.to_i) != 0
  data = Hash.new(0)
  flag = false
  n.times.each do |i|
    input = gets.chomp.split.map{|i|i.to_i}
	data["#{input[0]}"] += input[1] * input[2]
  end
  data.each do |key,val|
    if val >= 1000000
	  puts key
	  flag = true
	end
  end
  puts "NA" if !flag
end