int main(){

  int Sales[4001];
  int n,i,mem,price,amount,flag;

  while (1) {
    scanf("%d",&n);
    if(n==0)break;


    for(i=0;i<4001;i++){
      Sales[i]=0;
    }

    for(i=0;i<n;i++){
      scanf("%d",&mem);
      scanf("%d",&price);
      scanf("%d",&amount);
      Sales[mem]+=price*amount;
    }

    flag=0;

    for(i=1;i<4001;i++){
      if(Sales[i]>=1000000){
        printf("%d\n",i);
        flag=1;
      }
    }

    if(flag==0){
      printf("NA\n");
    }
  }

  return 0;
}
