#include <bits/stdc++.h>
int main() {
  int n;
  int i;
  int snum, p, s;
  int count;
  long syain[4001];
  do {
    count = 0;
    for (i = 0; i < 4000; i++) {
      syain[i] = 0;
    }
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &snum, &p, &s);
      if (syain[snum] < 1000000) {
        syain[snum] += p * s;
        if (syain[snum] >= 1000000) {
          printf("%d\n", snum);
          count++;
        }
      } else {
        syain[snum] += p * s;
      }
    }
    if (count == 0 && n != 0) {
      printf("NA\n");
    }
  } while (n != 0);
}
