# -*- coding: utf-8 -*-

import sys

while True:
	n = int(input())
	j = 0
	if n == 0:
		break
	salesmap = [0 for i in range(0,4001)]
	for i in range(n):
		a = input().split()
		salesmap[int(a[0])] += int(a[1])*int(a[2])
	for i in range(1,4001):
		if salesmap[i] >= 1000000:
			j += 1
			print(str(i))
	if j == 0:
		print('NA')
#print a # [a1, a2, a3, ..., aN]