import sys

l = []
temp = []
d = dict()
for input in sys.stdin:
    l.append(input)
i = 0
while(i < len(l)):
    j = i+1
    while(j <= int(l[i])+int(i)):
        temp = l[j].split()
        if(d.get(int(temp[0]),0) == 0):
            d[int(temp[0])] = int(temp[1])*int(temp[2])
        else:
            d[int(temp[0])] += int(temp[1])*int(temp[2])
        j += 1
    j = 0
    for key,value in d.items():
        if(value >= 1000000):
            print key
            j += 1
    if(j == 0 and int(l[i]) != 0):
        print 'NA'
    d.clear()
    i += (int(l[i])+1)
