while True:
    num=int(input())
    if num==0:
        break
    else:
        li=[]
        d={}
        for i in range (num):
            info=list(map(int,input().split()))
            try:
                d[info[0]]+=info[1]*info[2]
            except:
                d[info[0]]=info[1]*info[2]
                li.append(info[0])
    answer=[]
    for i in li:
        if d[i] >=1000000:
            answer.append(i)
    if answer==[]:
        print("NA")
    else:
        for i in answer:
            print(i)
            
    
            
        