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