#include <bits/stdc++.h>
int main(void) {
  int i, dataset, snum, flag;
  long long total[4000], unitcost, amount;
  while (1) {
    for (i = 0; i < 4000; i++) {
      total[i] = 0;
    }
    scanf("%d", &dataset);
    if (dataset == 0) {
      break;
    } else
      for (i = 0; i < dataset; i++) {
        scanf("%d %lld %lld", &snum, &unitcost, &amount);
        total[snum] += unitcost * amount;
      }
    flag = 0;
    for (i = 0; i < 4000; i++) {
      if (total[i] >= 1000000) {
        flag = 1;
        printf("%d\n", i);
      }
    }
    if (dataset != 0 && flag == 0) {
      printf("NA\n");
    }
  }
}
