while (n = gets.to_i) > 0
  shain, tanka, suryo = []*n, []*n, []*n
  0.upto(n-1) do |i|
    shain[i], tanka[i], suryo[i] = gets.split(" ").map(&:to_i)
  end
  shain_uriage_sum = {}
  0.upto(n-1) do |i|
    shain_uriage_sum[shain[i]] = 0 if shain_uriage_sum[shain[i]].nil?
    shain_uriage_sum[shain[i]] += tanka[i] * suryo[i]
  end
  flag = false
  shain_uriage_sum.each do |key,val|
    if val >= 1000000
      puts key
      flag = true
    end
  end
  puts "NA" if !flag
end