#include <bits/stdc++.h>
int main(int argc, const char *argv[]) {
  int i, n, num, price, set, flag;
  int employee[4000 + 1];
  long long int total;
  while (scanf("%d", &n) == 1 && n) {
    flag = 0;
    for (i = 0; i <= 4000; i++) {
      employee[i] = 0;
    }
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &num, &price, &set);
      total = price * set;
      if (total >= 1000000) {
        flag = 1;
        employee[num] = 1;
      }
    }
    if (flag) {
      for (i = 1; i <= 4000; i++) {
        if (employee[i]) {
          printf("%d\n", i);
        }
      }
    } else {
      printf("NA\n");
    }
  }
  return 0;
}
