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