while True:
    n=input()
    if n==0:
        break
    sale=[0]*4000
    raw=[]
    for unused in xrange(n):
        a,b,c=map(int,raw_input().split())
        sale[a]+=b*c
        if a not in raw:
            raw.append(a)
    ans=[i for i in raw if sale[i]>=1000000]
    if not ans:
        print "NA"
    else:
        print "\n".join(map(str,ans))