from sys import stdin


while True:
    n = int(stdin.readline())
    if n==0: break
    ps = []
    prd = {}
    for gomi in xrange(n):
        p,a,b = map(int,stdin.readline().split())
        if p in ps: r = prd.pop(p)+a*b
        else:
            ps.append(p)
            r = a*b
        prd.update({p:r})
    isNA = True
    for p in ps:
        if prd[p]>=1000000:
            print p
            isNA = False
    if isNA: print "NA"