def nz(a):
	if a is None:
		return 0
	else: return a

while 2 > 1:
	line_num = int(raw_input())
	if line_num < 1:
		print 'NA'
		break
	mydict = {}
	for n in range(line_num):
		dat = map(int, raw_input().split(" "))
		mydict[dat[0]] = nz(mydict.get(dat[0])) + dat[1] * dat[2]
	mylist = []
	flg = 0
	for n in mydict.keys():
		if mydict[n] > 999999:
			print str(n)
			flg = 1
	if flg == 0:
		print 'NA'