n = int(input())
while n != 0:
    score = {}
    j = 0
    for i in range(n):
        e,p,q = list(map(int,input().split()))
        if e in score:
            score[e]["value"] += p*q
        else:
            score[e] = {"value":p*q, "index":j}
            j += 1
    f = {}
    for e,v in score.items():
        if v["value"] >= 1000000:
            f[v["index"]] = e
    if len(f)==0:
        print("NA")
    else:
        for w in sorted(f.items(), key = lambda x:x[0]):
            print(w[1])
    n = int(input())