n = int(raw_input())
while n != 0:
    pass_flag = 0
    sales_dict = {}
    id_list = []
    for x in range(0, n):
        data = raw_input()
        data_list = map(int, data.split(' '))
        if not data_list[0] in sales_dict:
            sales_dict[data_list[0]] = data_list[1] * data_list[2]
            id_list.append(data_list[0])
        else:
            sales_dict[data_list[0]] += data_list[1] * data_list[2]
    for x in id_list:
        if  sales_dict[x] >= 1000000:
            print x
            pass_flag = 1
    if pass_flag == 0:
        print 'NA'
    n = int(raw_input())