while n = gets.to_i
  break if n == 0
  hash = {}
  n.times{|i|
    e, p, q = gets.split.map(&:to_i)
    hash[e] ||= 0
    hash[e] += p * q
  }
  flag = true
  hash.keys.each{|key|
    if hash[key] >= 1000000
      flag = false
      puts "#{key}"
    end
  }
  if flag
    puts "NA"
  end
end