#include <bits/stdc++.h>
int main() {
  int n;
  int id, price, num;
  bool f = false;
  int i;
  while (scanf("%d", &n), n) {
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", id, price, num);
      if (price * num > 1000000) {
        printf("%d\n", id);
        f = true;
      }
    }
    if (f) {
      printf("NA\n");
    }
  }
  return 0;
}
