lib = [0] * 4000

while True:
    a = int(input())
    if a == 0:
        break
    
    for _ in range(a):
        s,m,l = map(int, input().split())
        lib[s-1] +=  m*l
    
    if max(lib) <1000000:
        print("NA")
    else:
        for i in range(4000):
            if lib[i] >= 1000000:
                print(i+1)
    for i in range(4000):
        lib[i] = 0