#include <bits/stdc++.h>
struct AOJ0100 {
  int id;
  int tanka;
  int kosuu;
};
void initDouble(double array[], int n) {
  int i;
  for (i = 0; i < n; i++) {
    array[i] = 0.0;
  }
}
void initInt(int array[], int n) {
  int i;
  for (i = 0; i < n; i++) {
    array[i] = 0;
  }
}
int search_linear(int key, int array[], int n) {
  int i;
  for (i = 0; i < n; i++) {
    if (key == array[i]) {
      return 1;
    }
  }
  return 0;
}
int main() {
  int i, n;
  int count;
  int idArray[4000];
  int idLength;
  double score[4000];
  struct AOJ0100 data[4000];
  while (1) {
    initDouble(score, 4000);
    initInt(idArray, 4000);
    idLength = 0;
    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);
      if (!(search_linear(data[i].id, idArray, idLength))) {
        idArray[idLength] = data[i].id;
        idLength++;
      }
      score[data[i].id] += (double)(data[i].tanka * data[i].kosuu);
    }
    for (i = 0; i < idLength; i++) {
      if (score[idArray[i]] >= 1000000.0) {
        count++;
        printf("%d\n", idArray[i]);
      }
    }
    if (count == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
