#include <bits/stdc++.h>
typedef struct shain {
  int no;
  int tanka;
  int suuryou;
} Shain;
int main(void) {
  while (1) {
    int i, j, k, n, count;
    scanf("%d", &n);
    if (n == 0) {
      break;
    } else {
      count = 0;
      Shain array[n];
      for (j = 0; j < n; j++) {
        scanf("%d %d %d", &(array[j].no), &(array[j].tanka),
              &(array[j].suuryou));
      }
      for (k = 0; k < n; k++) {
        if ((array[k].tanka) * (array[k].suuryou) >= 1000000) {
          count++;
          printf("%d\n", array[k].no);
        }
      }
      if (count == 0) {
        printf("NA\n");
      }
    }
  }
  return 0;
}
