while n=gets.chomp.to_i
break if n==0

result=Hash.new{|id,total|total=0}

n.times{
	id,tanka,kosu=gets.chomp.split(" ").map{|i| i.to_i}
	result[id] += tanka*kosu
}

result.select!{|id,total| total >= 1000000}


if result=={}
		puts "NA"
	else
		puts result.keys
	end
end