while n = STDIN.gets
  n = n.chomp.to_i
  if n == 0 then break end
  sum = {}
  n.times do 
    line = STDIN.gets
    ipq = line.chomp.split(" ").map { |item| item.to_i } 
    if sum.has_key?(ipq[0]) == false then
      sum[ipq[0]]=0
    end
    sum[ipq[0]] += ipq[1]*ipq[2] 
  end
  flag=true
  sum.keys.each do |k|
    if sum[k] >= 1000000 then
      puts k
      flag=false
    end
  end
  if flag then
    puts "NA"
  end
end