while True:
    n=int(input())
    if n==0:
        break
    s=[-1]*4001
    id=[]
    for i in range(n):
        e,p,q=map(int,input().split())
        if s[e]<0:
            id.append(e)
            s[e]=p*q
        else:
            s[e]+=p*q
    ch=True
    for i in id:
        if s[i]>=1000000:
            print(i)
            ch=False
    if ch:
        print("NA")
