while True:
    n = int(input())
    if n == 0:
        break
    emp = [0] * 4001
    used = set()
    for i in range(n):
        e, p, q = map(int, input().split())
        emp[e] += p * q
        if 1000000 <= emp[e] and e not in used:
            print(e)
            used.add(e)
    if len(used) == 0:
        print("NA")
    