#include<stdio.h>

int main(){
	int num,age,tanka;
	int i,j,n,temp;
	int sya[4000];
	double uriage[4000];
	
	
	for(;;temp=0){
		for(i=0;i<n;i++)uriage[i]=0;
		scanf("%d", &n);
		if(n==0)break;
		
		for(i=0;i<n;i++){
			scanf("%d%d%d", &num, &tanka, &age);
			
			for(j=0;j<=i;j++){
				if(sya[j]==num){			//ÐõÔª êÎ½·B
					uriage[j]+=tanka*age;
					break;
				} else {					//»ÌÐõÔªÈ¯êÎVKÂ­éB
					sya[i]=num;
					uriage[i]+=tanka*age;
					break;
				}
			}
		}
		for(i=0;i<n;i++){
			if(uriage[i]>=1000000){			//POOÈãÍ\¦
				printf("%d\n",sya[i]);
				temp=1;
			}
		}
		if(temp==0)puts("NA");				//POOÈãªÈ¯êÎ\¦
	}
	return 0;
}