while 1:
    n=input()
    if n==0: break
    ans={}
    x=tuple([tuple(map(int,raw_input().split())) for _ in range(n)])
    for a,b,c in x:
        ans.setdefault(a,0)
        ans[a]+=b*c
    d=sorted(ans.items(), cmp=lambda x,y : x[0] < y[0])
    d=[k for k,v in d if v>=1000000]
    if len(d)==0:
        print 'NA'
    else:
        for z in d:
            print z