while True:
    n = int(input())
    if n == 0:
        break
    result = {}
    order = []
    for i in range(n):
        e, p, q = map(int, input().split())
        if e in result:
            result[e] += p*q
        else:
            result[e] = p*q
            order.append(e)
    flag = True
    for e_i in order:
        if result[e_i] >= 1000000:
            print(e_i)
            flag = False
    if flag:
        print("NA")

