while True:
	time=input()

	if time==0:
		break

	worr={}
	mem=[]

	for i in range(time):
		shain=map(int, raw_input().split())
		if shain[0] not in worr:
			worr[shain[0]]=shain[1]*shain[2]
			mem.append(shain[0])
		else:
			worr[shain[0]]+=shain[1]*shain[2]

	mem.sort()

	check=1
	for i in mem:
		if worr[i]>=1000000:
			print i
			check=0
	if check==0:
		print "NA"