#include <bits/stdc++.h>
int main() {
  char id[1024];
  for (;;) {
    int n;
    scanf("%d", &n);
    if (n == 0) return 0;
    int c = 0;
    for (int _ = 0; _ < (int)(n); _++) {
      int p, q;
      scanf("%s%d%d", id, &p, &q);
      if ((long long)p * q >= 1000000) {
        printf("%s\n", id);
        c++;
      }
    }
    if (c == 0) puts("NA");
  }
  return 0;
}
