from collections import defaultdict
while True:
    n = int(input())
    if n == 0:
        break

    SALES = defaultdict(int)
    for _ in range(n):
        id, p, num = [int(x) for x in input().split()]
        SALES[id] += p * num
        
    L = [k for k, v  in SALES.items() if v >= 1000000]

    if len(L) > 0:
        for i in L:
            print(i)
    else:
        print("NA")

