import sys
from collections import OrderedDict

data = OrderedDict()                                                              
for line in sys.stdin:                     
    lst = line.split(' ')
            
    if len( lst ) < 2:
        cnt = 0            
        for key, val in data.items():
            if val >= 1000000:
                print key
                cnt = cnt + 1
                                               
        if len( data ) != 0 and cnt == 0:
            print "NA"
                                               
        if lst[0] == 0:
            break
                                                         
        data = OrderedDict()
        continue
                                                  
    lst = map(int, lst)
    if lst[0] in data:
        data[ lst[0] ] = data[ lst[0] ] + lst[1]*lst[2]
    else:
        data[ lst[0] ] = lst[1]*lst[2]

sys.exit(0)