#include <stdio.h>
#include <string.h>

int main(void) {
int n;
int employees[4000] = {0};
while (1) {
scanf("%d", &n);
if (!n) break;

for (int i = 0; i < n; i++) {
int id, price, sales;
scanf("%d %d %d\n", &id, &price, &sales);
employees[id] += price * sales;
}

int found = 0;
for (int i = 0; i < n; i++) {
if (employees[i] >= 1000000) {
printf("%d\n", i);
found = 1;
}
}
memset(employees, 0, sizeof employees);
if (!found) {
printf("NA\n");
}

}
}