#include <bits/stdc++.h>
int main(void) {
  int n;
  int i;
  long long int x[4001];
  int e;
  long long int p, q;
  int state;
  while (scanf("%d", &n) != EOF) {
    if (n == 0)
      break;
    else {
      for (i = 0; i <= 4000; i++) x[i] = 0;
      for (i = 0; i < n; i++) {
        scanf("%d %lld %lld", &e, &p, &q);
        x[e] += p * q;
      }
      state = 0;
      for (i = 1; i <= 4000; i++) {
        if (x[i] >= 1000000.0) {
          printf("%d\n", i);
          state++;
        }
      }
      if (state == 0) printf("NA\n");
    }
  }
  return 0;
}
