l = int(input())
while l != 0:
	k = 0
	A = []
	B = []
	for l in range(0,l):
		li = input().split()
		if li[0] in A:
			i = A.index(li[0])
			B[i] = B[i] + (int(li[1]) * int(li[2]))
		else:
			A.append(li[0])
			B.append(int(li[1]) * int(li[2]))
	for j,b in enumerate(B):
		if b >= 10**6:
			print(A[j])
			k = 1
		
	if k == 0:
		print("NA")
	l = int(input())