n = int(input())
while n != 0:
    score = {}
    for i in range(n):
        e,p,q = list(map(int,input().split()))
        if e in score:
            score[e] += p*q
        else:
            score[e] = p*q
    f = True
    for e,v in score.items():
        if v >= 1000000:
            print(e)
            f = False
    if f:
        print("NA")
    n = int(input())