# Aizu Problem 0100: Sale Result
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    N = int(input())
    if N == 0:
        break
    sales = {}
    good = False
    order = []
    for n in range(N):
        i, p, q = [int(_) for _ in input().split()]
        if i not in order:
            order.append(i)
        sales[i] = sales.get(i, 0) + p * q
    good = False
    for i in order:
        if sales[i] >= 1000000:
            print(i)
            good = True
    if not good:
        print("NA")