loop{
  n=gets.to_i
  if n == 0 then 
    break
  end
  hash=Hash.new("none")
  n.times do
    str=gets.chop.split(" ").map{|buf| buf.to_i}
    if hash.key?(str[0]) then 
      hash[str[0]]+=str[1]*str[2]
      else
      hash[str[0]]=str[1]*str[2]
    end
  end
  i=0
  hash.each {|key,value|
    if value >=  1_000_000 then
      puts(key)
      i+=1
    end

  }
  if i == 0 then 
    puts("NA")
  end
}