#include <bits/stdc++.h>
long long int num, sale, deal;
long long int n, i, j, count, k;
long long int id[4001];
int main() {
  while (1) {
    scanf("%lld", &n);
    for (k = 0; k <= 4001; k++) {
      id[k] = 0;
    }
    if (n == 0) {
      return 0;
    } else {
      count = 0;
      for (i = 1; i <= n; i++) {
        scanf("%lld %lld %lld", &num, &sale, &deal);
        id[num] = id[num] + (sale * deal);
      }
      for (j = 1; j < 4001; j++) {
        if (id[j] >= 1000000) {
          printf("%lld\n", j);
          count++;
        }
      }
      if (count == 0) {
        printf("NA\n");
      }
    }
  }
  return 0;
}
