#include <stdio.h>

int main(){
  int setsize;
  int i;
  int num
  long tanka, suuryo;
  long uriage[4001][2];
  int order[4001];
  int count;
  int na_flag;

  for(i=1; i<4001; i++){
    uriage[i][0]=0; uriage[i][1]=0; 
  }
  while(1){
    scanf("%d", &setsize);
    if(setsize==0) break;
    count=0; na_flag=1;
    for(i=0; i<setsize; i++){
      scanf("%d %ld %ld", &num, &tanka, &suuryo);
      if(uriage[num][0]==0){
        order[count]=num; count++;
      }
      uriage[num][0]+=tanka*suuryo;
      if(uriage[num][0]>=1000000) uriage[num][1]=1;
    }
    for(i=0; i<count; i++){
      num=order[i];
      if(uriage[num][1]==1){
        printf("%d\n", num);
        na_flag=0;
      }
      uriage[num][0]=0; uriage[num][1]=0;
    }
    if(na_flag) printf("NA\n");
  }

  return 0;
}