lim = 1000000
while true do
  i=0
  h = Hash.new
  n=STDIN.gets.to_i
  break  if n ==0
#h[id] = [jyun,uri]
  0.upto(n-1){|jun|
    id, tanka, ryou = gets.chomp.split.map{|x| x.to_i}
    if h.has_key?(id) then
      h[id][1] += tanka*ryou
    else
      h[id] = [jun, tanka*ryou]
    end
  }
#[[id,[jun,uriage]],...]
  f = h.to_a.sort{|a,b| a[1][0]<=>b[1][0]}.select{|x|x[1][1] >= lim}.map{|x| x[0]}
  puts f.length==0 ? "NA" : f
end