import sys
import math


while 1:
    para = map(int, raw_input())
    if (para == 0):
        break
    ans = 0
    l = [0 for i in range(4000)]
    num = []
    check = 0
    for j in range(para):
        data = map(int, raw_input().split())
        l[data[0]] = l[data[0]]+data[1]*data[2]
        if(data[0] not in num):
            num.append(data[0])
    for j in range(4000):
        if(l[num[j]]>=1000000):
            print num[j]
            check = check + 1
    if(check==0):
        print "NA"