#include <stdio.h>
 
int n,num[4000];
long long int tanka[4000],sale_num[4000],sale_all[4001];
bool judge[4001];
 
int main(void)
{
int i,j,k;
     
while(scanf("%d",&n),n){
    for(i=0;i<n;i++){
        scanf("%lld %lld %lld",&num[i],&tanka[i],&sale_num[i]);
    }
    k=0;
    for(j=0;j<4001;j++){
    judge[j]=0;
    sale_all[i]=0;
    }
    for(i=0;i<n;i++){
        sale_all[num[i]] += tanka[i]*sale_num[i];
    }
    for(i=0; i < n; i++){
        if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
            printf("%d\n",num[i]);
            judge[num[i]]=1;
            k=1;
        }
    }
    if(k!=1)printf("NA\n");
}
 
    return 0;
}