import sys
import collections

thre = 1000000
while 1:
    n = int(raw_input())
    if(n==0):break;
    dic1 = collections.OrderedDict()
    exceed = False
    for i in range(n):
        (a,b,c) = map(int , raw_input().split())
        pre = 0
        if(a in dic1): pre =dic1[a]
        dic1[a] = pre + b * c
        if(dic1[a]>=thre):exceed = True
    if(exceed==False):print "NA"; continue 
    for k in dic1.keys():
        if(dic1[k]>=thre):print k