class Member():
	def __init__(self, mi):
		self.member_id	= int(mi)
		self.datalist = []
		
	def addData(self, pr, sn):
		self.datalist.append([int(pr), int(sn)])

	def calc(self):
		sum = 0
		for p, s in self.datalist:
			sum += p * s
		
		return sum
			

output_list = []
members = []
member_dict = {}

while 1:
	n = int(raw_input())
	if n == 0:
		break
	
	dataset = [raw_input() for i in range(n)]
	
	for item in dataset:
		rawlist = map(int, item.split())
		
		if rawlist[0] not in [mem.member_id for mem in members]:
			member_dict[rawlist[0]] = Member(rawlist[0])
			members.append( member_dict[rawlist[0]] )
		
		member_dict[rawlist[0]].addData(rawlist[1], rawlist[2])
		
	output_list_length = len(output_list)
	for mem in members:
		if mem.calc() >= 1000000:
			output_list.append(mem.member_id)
		
		if output_list_length == len(output_list):
			output_list.append("NA")
			
	members = []
	member_dict = {}
			

for s in output_list:
	print s