#include <bits/stdc++.h>
int main(void) {
  int a, b, c, d;
  int i, j, k;
  int count;
  count = 0;
  for (;;) {
    scanf("%d", &a);
    if (a == 0) break;
    for (i = 0; i <= a; i++) {
      scanf("%d%d%d", &b, &c, &d);
      if (c * d >= 1000000) {
        printf("%d", b);
        count++;
      }
      if (count == 0) printf("NA\n");
    }
  }
  return 0;
}
