#include <bits/stdc++.h>
int main(void) {
  int i;
  int kazu;
  int bangou;
  unsigned long long uriagelist[4001];
  unsigned long long tanka, uriage;
  int found;
  while (1) {
    scanf("%d", &kazu);
    if (kazu == 0) break;
    for (i = 1; i <= 4000; i++) uriagelist[i] = 0;
    for (i = 0; i < kazu; i++) {
      scanf("%d %llu %llu", &bangou, &tanka, &uriage);
      uriagelist[bangou] += tanka * uriage;
    }
    found = 0;
    for (i = 1; i <= 4000; i++) {
      if (uriagelist[i] >= 1000000ULL) {
        printf("%d\n", i);
        found = 1;
      }
    }
    if (found == 0) puts("NA");
  }
  return 0;
}
