import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break
    members = []
    sales  = {}
    for i in range(n):
        e,p,q = sys.stdin.readline().rstrip().split(' ')
        if not e in members:
            members.append(e)
            sales[e] = 0
        sales[e] += int(p) * int(q)
    ret = [member for member in members if sales[member] >= 1000000]
    if len(ret) != 0:
        for d in ret:
            print(d)
    else:
        print("NA")