while True:
    try:
        n=int(input())
    except:
        break
    if n==0:
        break
    data={}
    staff=[]
    for i in range(n):
        spam=list(map(int,input().split()))
        if spam[0] in data.keys():
            data[spam[0]]+=spam[1]*spam[2]
        else:
            data[spam[0]]=spam[1]*spam[2]
            staff.append(spam[0])
    if max(data.values())<1000000:
        print('NA')
    else:
        for i in staff:
            if data[i] >= 1000000:
                print(i)