while True:
    n = int(input())
    if n == 0:
        break
    data = [0] * 4001
    for _ in range(n):
        e, p, q = map(int, input().split())
        data[e] += p*q

    flag = True
    for i in range(1, 4001):
        if data[i] >= 1000000:
            print(i)
            flag = False
    if flag:
        print("NA")