#include <bits/stdc++.h>
typedef struct {
  long num;
  long point;
} person_t;
int main() {
  while (1) {
    int n, pnum, i, j, s = 0;
    person_t persons[4000];
    for (i = 0; i < 4000; i++) {
      persons[i].num = 0;
      persons[i].point = 0;
    }
    scanf("%d", &n);
    if (n == 0) return 0;
    for (i = 0; i < n; i++) {
      long e, p, q;
      scanf("%ld %ld %ld", &e, &p, &q);
      for (j = 0; j < i; j++) {
        if (persons[j].num == e) {
          persons[j].point += p * q;
          j = i;
          break;
        }
      }
      if (j == i) {
        persons[i].num = e;
        persons[i].point = p * q;
        pnum++;
      }
    }
    for (i = 0; i < pnum; i++) {
      if (persons[i].point >= 1000000) {
        printf("%ld\n", persons[i].num);
        s++;
      }
    }
    if (s == 0) puts("NA");
  }
}
