while (n=gets.to_i) != 0 do
	es = {}
	n.times do
		e, p, q = gets.split.map(&:to_i)
		es[e] ||= 0
		es[e] += p * q
	end
	some = false
	es.each_pair do |e,sell|
		if sell >= 1000000
				p e
				some = true
		end
	end
	unless some
			puts "NA"
	end
end