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