while True:
    n = int(raw_input())
    if n == 0:
        break
    sale = {}    
    
    for i in range(n):
        j,p,q = map(int,raw_input().split())
        if j in sale:
            sale[j] += p * q
        else:
            sale[j] = p * q
         
    existflag = False
    for j in sale:
        if(sale[j] >= 1000000):
            print j
            existflag = True
    if(not existflag):
        print 'NA'
            