
import sys


class Person:
    def __init__(self, number):
        self.number = number
        self.total_sales = 0

    def sales(self, price, quantity):
        self.total_sales += price * quantity


while True:
    n = int(sys.stdin.readline())
    if n == 0:
        exit()
    persons = []
    for i in range(n):
        num, price, quantity = tuple(map(int, sys.stdin.readline().split(' ')))
        person = filter(lambda x: x.number == num, persons)
        if person:
            person[0].sales(price, quantity)
        else:
            person = Person(num)
            person.sales(price, quantity)
            persons.append(person)
    over_million = filter(lambda x: x.total_sales >= 1000000, persons)
    if not over_million:
        print 'NA'
    else:
        for p in over_million:
            print p.number