from collections import defaultdict

while True:
    n = int(input())
    if n == 0:
        break

    dv = defaultdict(int)
    for _ in range(n):
        e, p, q = list(map(int, input().split()))
        dv[e] += p * q
    
    count = 0
    for k, v in dv.items():
        if v >= 1000000:
            print(k)
            count += 1
    if count == 0:
        print("NA")
