#include <stdio.h>
#include <string.h>
 
int main(void) {
    int n;
    int employees[4000] = {0};
    while (~scanf("%d", &n) && n) {
        for (int i = 0; i < n; i++) {
            int id, price, sales;
            scanf("%d %d %d", &id, &price, &sales);
            employees[id-1] += price * sales;
        }
 
        int found = 0;
        for (int i = 0; i < 4000; i++) {
            if (employees[i] >= 1000000) {
                printf("%d\n", i+1);
                found = 1;
            }
        }
        memset(employees, 0, sizeof employees);
        if (!found) {
            printf("NA\n");
        }
 
    }
 
    return 0;
}