import collections
while 1:
	li=collections.defaultdict(int)
	n=int(input())
	if n==0:
		break
	for i in range(n):
		(emp,prc,num)=list(map(int,input().split()))
		li[emp]+=prc*num
	tmp=True
	for i,j in li.items():
		if j>=1000000:
			print(i)
			tmp=False
	if tmp:
		print("NA")
	li.clear()		