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