#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[4000 + 1];
  while (scanf("%d", &n) == 1 && n) {
    flag = 1;
    for (i = 0; i <= 4000; i++) {
      employee[i] = 1;
      total[i] = 0;
    }
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &num, &price, &set);
      total[num] += price * set;
      if (total[num] >= 1000000 && employee[num]) {
        flag = 0;
        employee[num] = 0;
        printf("%d\n", num);
      }
    }
    if (flag) {
      printf("NA\n");
    }
  }
  return 0;
}
