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