#include <bits/stdc++.h>
int main(void) {
  int num, in[3], chk, i;
  for (;;) {
    scanf("%d", &num);
    if (num == 0) return 0;
    chk = 0;
    for (i = 0; i < num; i++) {
      scanf("%d %d %d", &in[0], &in[1], &in[2]);
      if (in[1] * in[2] >= 1000000) {
        printf("%d\n", in[0]);
        chk++;
      }
    }
    if (chk == 0) printf("NA\n");
  }
}
