
while True:
	n = int(raw_input())
	if n == 0:
		break
	employee_no = []
	info = {}
	for r in range(n):
		no,unit_price,quantity = map(int, raw_input().split(' '))
		if no in info:
			info[no] += unit_price*quantity
		else:
			info[no] = unit_price*quantity
		if not no in employee_no:
			employee_no.append(no)
	output_flg = False
	for no in employee_no:
		if info[no] >= 10**6:
			output_flg = True
			print no
	if not output_flg:
		print "NA"