
    long int shain[4000];
    int million[4000];
    int n;
    int i;
    int c;
    long int bango,tanka,kosu;
    
    scanf("%d",&n);
    
    while(n!=0){
        for(i=0;i<4000;i++){
            shain[i]=0;
            million[i]=0;
        }
        
        for(i=0;i<n;i++){
            scanf("%d %d %d",&bango,&tanka,&kosu);
            shain[bango-1]+=tanka*kosu;
        }
        
        for(i=0;i<4000;i++){
            if(shain[i]>=1000000){
                million[c]=i+1;
                c++;
            }
        }
        if(c==0){
            printf("NA\n");
        }else{
            for(i=0;i<c;i++){
                printf("%d\n",million[i]);
            }
        }
        
        scanf("%d",&n);
        c=0;
    }
    
    return 0;
}