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