while True:
    a = input()
    if a == 0: break
    ans = {}
    for i in range(a):
        mo = map(int,raw_input().split(" "))
        if str(mo[0]) in ans.keys():
            ans[str(mo[0])] += mo[1]*mo[2]
        else:
            ans[str(mo[0])] = mo[1]*mo[2]
    ans2 =0
    for j in ans:
        if ans[j] >= 1000000:
            print j
            ans2 +=1
        else:
            pass
    else:
        if ans2 == 0:
            print "NA"