#include <bits/stdc++.h>
int main(void) {
  unsigned int uri[4000];
  unsigned int i, n, flg;
  unsigned int id, tan, kazu;
  while (scanf("%u", &n) && n != 0) {
    for (i = 0; i < 4000; i++) uri[i] = 0;
    for (i = 0; i < n; i++) {
      scanf("%u %u %u", &id, &tan, &kazu);
      uri[id - 1] += tan * kazu;
    }
    for (flg = 0, i = 0; i < 4000; i++) {
      if (uri[i] >= 1000000) {
        printf("%u\n", i + 1);
        flg = 1;
      }
    }
    if (flg == 0) puts("NA");
  }
  return 0;
}
