while True:
    n = int(input())
    if n == 0:
        break
    ID = []
    sales = {}
    for i in range(n):
        ipq = list(map(str, input().split()))
        ID = int(ipq[0])
        pq = int(ipq[1]) * int(ipq[2])
        if ID in sales:
            sales[ID] += pq
        else:
            sales[ID] = pq
    t = -1
    for k, v in sales.items():
        if v >= 1000000:
            print(k)
            t = 1
    if t == -1:
        print("NA")