while true 
	hash = Hash.new

	n = gets.to_i  #???????????°
	break if n == 0
	for r in 0...n do 
		line = gets.chomp!
		line = line.split

		no = line[0].to_i #????????????
		unitPrice = line[1].to_i #????£???????
		quantity = line[2].to_i #?£??????°???
		total = unitPrice * quantity #?°??¨?

		if hash.key?(no)
			total += hash[no]
		end
		
		hash[no] = total
	end

	if hash.select{|key, val| val >= 1000000}.empty?
		p "NA"
	else
		hash.each{ |key, val|
			if val >= 1000000
				p key
			end
		}
	end
end	