while True:
    try:
        n=int(input())
    except:
        break
    if n==0:
        break
    data=[]
    for i in range(n):
        spam=[x for x in map(int,input().split())]
        if spam[1]*spam[2]>=1000000:
            if (spam[0] in [b[0] for b in data])==False:
                data.append(spam)
    if len(data)==0:
        print('NA')
    else:
        for i in [b[0] for b in data]:
            print(i)