#include<stdio.h>

int main(){
	int num,age,tanka;
	int i,j,n,temp;
	int sya[4000];
	double uriage[4000][2]={ 0 };
	
	
	for(;;temp=0){
		scanf("%d", &n);
		
		for(i=0;i<n;i++){
			scanf("%d%d%d", &num, &tanka, &age);
			
			for(j=0;j<=i;j++){
				if(sya[j]==num){
					uriage[j][0]+=tanka*age;
					break;
				} else {
					sya[i]=num;
					uriage[i][0]+=tanka*age;
					break;
				}
			}
		}
		for(i=0;i<4000;i++){
			if(uriage[i][0]>=1000000 && uriage[i][1] != 1){
				uriage[i][1]=1;
				temp=1;
				break;
			}
		}
		if(temp==1)printf("%d\n",sya[i]);
		else puts("NA");
		if(n==0)break;
	}
	return 0;
}