
def add(lis,check_list):
    for index in range(len(lis)):
        if lis[index][0]==check_list[0]:
            lis[index][1]+=int(check_list[1])*int(check_list[2])
            return
    lis.append([check_list[0],int(check_list[1])*int(check_list[2])])

while True:
    num=int(raw_input())
    if num==0: break
    lis=[]
    for i in range(num):
        l=raw_input().split(" ")
        add(lis,l)
    c=0
    for ele in lis:
        if ele[1]>=1000000:
            print ele[0]
            c+=1
    if c==0: print "NA"