loop do
	n = gets.to_i
	break if n.zero?

	hash = Hash.new(0)
	n.times do
		i, p, q = gets.split.map(&:to_i)
		hash[i] += p * q
	end

	good_workers = hash.select{|k, v| 1_000_000 <= v}.keys
	puts good_workers.empty?? 'NA' : good_workers
end