# coding: utf-8
# Here your code !

dataCount = int(input())
while dataCount > 0:
    employeeSalesList = []
    for _ in range(dataCount):
        dataList = input().split(" ")
        employeeId, price = int(dataList[0]), int(dataList[1]) * int(dataList[2])
        found = False
        for data in employeeSalesList:
            if data[0] == employeeId:
                data[1] += price
                found = True
        if not found:
            employeeSalesList.append([employeeId, price])

    answerList = [data[0] for data in employeeSalesList if data[1] >= 1000000]
    if answerList:
        print("\n".join(map(str, answerList)))
    else:
        print("NA")

    dataCount = int(input())