while True:
    n=int(input())
    if n==0:break
    d=dict()
    for _ in range(n):
        i,p,q=map(int, input().split())
        d[i] = d[i]+p*q if i in d else p*q
    b=True
    for k, v in d.items():
        if v >= 1000000:
            print(k)
            b=False
    else:
        if b:print("NA")