#include <bits/stdc++.h>
int main(void) {
  int n = 0;
  int end = 0;
  while (end >= 0) {
    scanf("%d", &n);
    if (n == 0) {
      end = -1;
      continue;
    }
    int i = 0;
    int e, p, q = 0;
    int sum = 0;
    while (i < n) {
      scanf("%d %d %d", &e, &p, &q);
      if (p * q >= 1000000) {
        printf("%d\n", e);
        sum++;
      }
      i++;
    }
    if (sum == 0) {
      puts("NA");
    }
    end++;
    if (end >= 50) break;
  }
  return 0;
}
