#include <bits/stdc++.h>
void Initialization(int[], int *);
int main() {
  int d[4001];
  int flg, n, e, p, q;
  while (scanf("%d", &n), n != 0) {
    Initialization(d, &flg);
    for (n; n > 0; --n) {
      scanf("%d%d%d", &e, &p, &q);
      d[e] += p * q;
      flg = d[e] >= 1000000;
    }
    if (!flg)
      puts("NA");
    else
      for (n = 1; n < 4001; n++)
        if (d[n] >= 1000000) printf("%d\n", n);
  }
  return 0;
}
void Initialization(int d[], int *flg) {
  int i;
  for (i = 1; i < 4001; i++) d[i] = 0;
  flg = 0;
}
