while True:
	N= int(input())
	if N == 0:
		break
	D = {}
	di = []
	for n in range(N):
		e,p,q = input().split()
		p = int(p)
		q = int(q)
		if e not in di:
			di.append(e)
			D[e] = p * q
		else:
			D[e] = D[e] + p * q
	flag = 0
	for dj in di:
		if D[dj] >= 10**6:
			print(dj)
			flag = 1
	if flag == 0:
		print("NA")
	