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