n = int(input())
while n != 0:
	earnings = []
	for i in range(0,n):
		a = str.split(input(),' ')
		if i > 0 :
			for j in range(0,len(earnings)):
				if a[0] == earnings[j][0]:
					earnings[j][1] = str(int(earnings[j][1])+(int(a[1])*int(a[2])))
					break
				if j == len(earnings) - 1:earnings.append([a[0],str(int(a[1])*int(a[2]))])
		else:earnings.append([a[0],str(int(a[1])*int(a[2]))])
	milionear = []
	for i in range(0,len(earnings)):
		if int(earnings[i][1]) >= 1e6:
			milionear.append(earnings[i][0])
	if len(milionear) == 0 : print('NA')
	else:
		for i in range(0,len(milionear)):
			print(milionear[i])
	n = int(input())