import sys

def sales_result(sales):
    total_sales = {}
    person = []
    for s in sales:
        total_sales[s[0]] = total_sales.get(s[0], 0)
        total_sales[s[0]] += s[1] * s[2]
        if total_sales[s[0]] >= 1000000 and not (s[0] in person):
            person.append(s[0])
    if len(person) == 0:
        print("NA")
    else:
        for p in person:
            print(p)


lineno = 0
n = 0
sales = []
for line in sys.stdin:
    if lineno == 0:
        n = int(line)
        if n == 0:
            break
    elif lineno <= n:
        s = list(map(int, line.strip().split()))
        sales.append(s)
    if lineno == n:
        sales_result(sales)
        lineno = 0
        sales = []
    else:
        lineno += 1

