#include <bits/stdc++.h>
int main() {
  long long sales[4000] = {0};
  char buf[20];
  int data_cnt;
  long long emp_num, unit_cost, unit_num;
  int cnt, i;
  while (fgets(buf, 20, stdin) != NULL) {
    if (sscanf(buf, "%d", &data_cnt) < 1) {
      fprintf(stderr, "error:invalid input\n");
    } else if (data_cnt == 0) {
      break;
    } else {
      for (i = 0; i < 4000; i++) sales[i] = 0;
      while ((data_cnt > 0) && (fgets(buf, 20, stdin) != NULL)) {
        if (sscanf(buf, "%lld %lld %lld", &emp_num, &unit_cost, &unit_num) <
            3) {
          fprintf(stderr, "error:invalid input2\n");
        } else {
          sales[emp_num - 1] += unit_cost * unit_num;
          data_cnt--;
        }
      }
      cnt = 0;
      for (i = 0; i < 4000; i++) {
        if (sales[i] >= 1000000) {
          printf("%d\n", i + 1);
          cnt++;
        }
      }
      if (cnt == 0) printf("NA\n");
    }
  }
  return 0;
}
