#include <bits/stdc++.h>
struct AOJ0100 {
  int id;
  int tanka;
  int kosuu;
};
void init(double array[], int n) {
  int i;
  for (i = 0; i < n; i++) {
    array[i] = 0.0;
  }
}
int main() {
  int i, n;
  int count;
  double score[4000];
  struct AOJ0100 data[4000];
  while (1) {
    init(score, 4000);
    count = 0;
    scanf("%d", &n);
    if (!n) {
      break;
    }
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &data[i].id, &data[i].tanka, &data[i].kosuu);
      score[data[i].id] += (double)(data[i].tanka * data[i].kosuu);
    }
    for (i = 0; i < 4000; i++) {
      if (score[i] >= 1000000.0) {
        count++;
        printf("%d\n", i);
      }
    }
    if (count == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
