while True:
    n = int(raw_input())
    if n == 0:
        break
    sale = {}
    order = []
    
    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
            order.append(j)
         
    existflag = False
    for j in order:
        if sale[j] >= 1000000:
            print j
            existflag = True
    if not existflag:
        print 'NA'