#include <bits/stdc++.h>
int num, sale, deal, n, i, j, count, k;
int id[4001];
int main() {
  while (1) {
    for (k = 0; k <= 4001; k++) {
      id[k] = 0;
    }
    scanf("%d", &n);
    if (n == 0) {
      return 0;
    } else {
      count = 0;
      for (i = 1; i <= n; i++) {
        scanf("%d %d %d", &num, &sale, &deal);
        id[num] = id[num] + (sale * deal);
      }
      for (j = 1; j < 4001; j++) {
        if (id[j] >= 1000000) {
          printf("%d\n", j);
          count++;
        }
      }
      if (count == 0) {
        printf("NA\n");
      }
    }
  }
}
