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