#include <stdio.h>
#include <stdbool.h>

int main(void)
{
    int data_num, data_num_update;
    int employee_num[4000] = {};
    long long employee_sale_num[4000] = {};
    long long employee_sale[4000] = {};
    
    while ((scanf("%d", &data_num)) != EOF) {
        
        if (data_num == 0) break;
        
        data_num_update = data_num;
        for (int i = 0; i < data_num; ++i) {
            scanf("%d %lld %lld", &employee_num[i], &employee_sale_num[i],  &employee_sale[i]);
        }
        
        int data_check = 0;

        while (data_check < data_num - 1) {
            for (int i = data_check + 1; i < data_num; ++i) {
                if (employee_num[data_check] == employee_num[i]) {
                    employee_sale[data_check] += employee_sale[i];
                    employee_sale_num[data_check] += employee_sale_num[i];
                    data_num_update--;
                }

                
            }
            data_check++;
            
        }
        
        //printf("%d", data_num_update);
        
        bool result_flag = true;
        for (int i = 0; i < data_num_update; ++i) {
            if (employee_sale_num[i] * employee_sale[i] >= 1000000) {
                printf("%d\n", employee_num[i]);
                result_flag = false;
            }
            
            if (result_flag) {
                printf("NA\n");
                break;
            }
        }
    }

    return 0;
}