while True:
	n = int(raw_input())
	if n == 0:
		break
	
	dict = {}
	list = []
	for i in xrange(n):
		a,b,c = map(int,raw_input().split())
		
		if a in dict:
			dict[a] = dict[a] + b * c
		else:
			dict[a] = b * c
			
	for var in dict:
		if dict[var] >= 1000000:
			list.append(var)
			
	if len(list) == 0:
		list.append("NA")
			
	for var in list:
		print var