import sys
from collections import OrderedDict
#from me.io import dup_file_stdin

#@dup_file_stdin
def solve():
    while True:
        n = int(sys.stdin.readline())
        if n==0 :
            break
        emps = OrderedDict()
        for i in range(n):
            no,price,amount = map(int,sys.stdin.readline().split(' '))
            emps[no]=emps.get(no,0)+price*amount
        results = [k for k,v in emps.items() if v>=1000000]
        if len(results) > 0:
            [print(emp) for emp in results]
        else:
            print("NA")
solve()
        