#include <bits/stdc++.h>
long int members_number[4001];
void reset(void) {
  int i;
  for (i = 0; i < 4001; i++) {
    members_number[i] = 0;
  }
}
void scan_result(int n) {
  int staff, price, number, i;
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &staff, &price, &number);
    members_number[staff] += price * number;
  }
}
void output(void) {
  int i, count = 0;
  for (i = 1; i < 4001; i++) {
    if (members_number[i] >= 1000000) {
      printf("%d\n", i);
      count = 1;
    }
  }
  if (!count) {
    puts("NA");
  }
}
int main(void) {
  int n;
  scanf("%d", &n);
  while (n) {
    reset();
    scan_result(n);
    output();
    scanf("%d", &n);
  }
  return 0;
}
