#include <bits/stdc++.h>
typedef struct {
  int number;
  int tanka;
  int n;
  int kingaku;
} TAG_T;
TAG_T dt[(4000)];
int dt_num;
int main() {
  int n;
  int number, tanka, nn, flg, len;
  int i;
  char inp[96];
  while (1) {
    dt_num = 0;
    gets(inp);
    sscanf(inp, "%d", &n);
    if (n == 0) {
      return 0;
    }
    for (i = 0; i < n; i++) {
      gets(inp);
      len = strlen(inp);
      if (len == 0) {
        return 1;
      }
      sscanf(inp, "%d %d %d", &number, &tanka, &nn);
      dt[dt_num].number = number;
      dt[dt_num].tanka = tanka;
      dt[dt_num].n = nn;
      dt[dt_num].kingaku = tanka * nn;
      dt_num++;
    }
    flg = 0;
    for (i = 0; i < n; i++) {
      if (dt[i].kingaku >= 1000000) {
        printf("%d\n", dt[i].number);
        flg++;
      }
    }
    if (flg == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
