while True:
	n=int(input())
	if n==0: break
	a=[list(map(int,input().split())) for _ in range(n)]
	d={}
	for i in range(n):
		if a[i][0] in d:
			d[a[i][0]]+=a[i][1]*a[i][2]
		else:
			d[a[i][0]]=a[i][1]*a[i][2]
	for k in d.keys():
		if d[k]>=1000000:
			print(k)
	if max(d.values())<1000000:
		print("NA")