while True:
    n=int(input())
    if n==0:break
    res={}
    li=[]
    for i in range(n):
        d=[int(num) for num in input().split(' ')]
        res[d[0]-1]+=d[1]*d[2]
        if d[0]-1 not in li:li.append(d[0]-1)
    flag=False
    for i in li:
        if res[i]>=1000000:
            print(i+1)
            flag=True
    if flag==False:print("NA")