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