#include <stdio.h>

long long int members_number[4001];

void reset(void) {
  int i;
  for(i = 0; i < 4001; i++ ) {
    members_number[i] = 0;
  }
}

void scan_result(long int n) {
  int staff, number, i;
  long long int price;
  for(i = 0; i < n; i++ ) {
    scanf("%d %lld %d",&staff, &price, &number);
    members_number[staff] += price * number;
  }
}

void output(void) {
  int i, flag = 0;
  for(i = 1; i < 4001; i++ ) {
    if(members_number[i] >= 1000000) {
      printf("%d\n",i);
      flag = 1;
    }
  }
  if(!count) {
    puts("NA");
  }
}

int main(void) {
  long int n;
  scanf("%ld",&n);
  while(n) {
    reset();
    scan_result(n);
    output();
    scanf("%ld",&n);
  }
  return 0;
}