# coding:utf-8

while (True):
    inputCount = int(input())

    if inputCount == 0:
        break

    employeeNumber = []
    employeePrice = []

    while 0 < inputCount:
        inputNum = [int(item) for item in input().split(" ")]

        price = inputNum[1] * inputNum[2]

        if inputNum[0] in employeeNumber:
            index = employeeNumber.index(inputNum[0])
            employeePrice[index] += price
        else:
            employeeNumber.append(inputNum[0])
            employeePrice.append(price)

        inputCount -= 1

    isExist = False

    for index in range(0, len(employeeNumber)):
        if 1000000 <= employeePrice[index]:
            print(employeeNumber[index])
            isExist = True

    if not isExist:
        print("NA")

