while 1:
    n=int(input())
    if n==0:break
    a={};c=[]
    for _ in range(n):
        b=list(map(int,input().split()))
        if b[0] in a:a[b[0]]+=b[1]*b[2]
        else:a[b[0]]=b[1]*b[2];c.append(b[0])
    if max(a.values())<=999999:print('NA' )
    for i in c:
        if a[i]>999999:print(i)