while True:
	n = int(input())
	if n == 0:
		break
	workers = {}
	greatworkers = 0
	for i in range(n):
		person, price, number = map(int, input().split())
		if person in workers:
			workers[person] += price * number
		else:
			workers[person] = price * number
	for worker in workers:
		if workers[worker] >= 1000000:
			print(worker)
			greatworkers += 1	
	if greatworkers == 0:
		print('NA')