import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break
    member = {}
    for i in range(n):
        e,p,q = sys.stdin.readline().rstrip().split(' ')
        if not e in member.keys():
            member[e] = 0
        member[e] += int(p) * int(q)
    ret = sorted(member.items(), key=lambda d: d[1])[::-1]
    ret = [k for k,v in ret if v >= 1000000]
    if len(ret) != 0:
        for d in ret:
            print(d)
    else:
        print("NA")