# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=jp
"""
import sys


def solve(data):
    result = []
    total_sales = [0 for _ in range(4000+1)]
    for id, unit_price, quantity in data:
        total_sales[id] += unit_price * quantity
        if total_sales[id] >= 1000000:
            if id not in result:
                result.append(id)

    #for i, sales in enumerate(total_sales):
    #    if sales >= 1000000:
    #        result.append(i)
    return result


def main(args):
    #data = []
    #data.append([1001, 2000, 520])
    #data.append([1002, 1800, 450])
    #data.append([1003, 1600, 625])
    #data.append([1001, 200, 1220])
    while True:
        num = int(input())
        if num == 0:
            break
        data = []
        for _ in range(num):
            data.append([int(x) for x in input().split(' ')])
        result = solve(data)
        if result:
            for ele in result:
                print(ele)
        else:
            print('NA')


if __name__ == '__main__':
    main(sys.argv[1:])