#include <bits/stdc++.h>
int main() {
  int n, id, tan, kazu, i, count = 0, sum;
  while (1) {
    count = 0;
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &id, &tan, &kazu);
      sum = tan * kazu;
      if (sum >= 1000000) {
        printf("%d\n", id);
        count++;
      }
    }
    if (count == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
