#include<stdio.h>

void set_zero(int v[]){
	int i;
	for(i=0;i<4001;i++){
		v[i]=0;
	}
}

int main(void){
	int n;
	int number[4001];
	int price[4001];
	int kosu[4001];
	int harasyo[4001];
	long long int sum[4001];
	int i,j;
	int flag;
	while(scanf("%d",&n)){
		set_zero(harasyo);
		set_zero(sum);
		flag=0;
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%d %d %d",&number[i],&price[i],&kosu[i]);
			sum[i]=price[i]*kosu[i];
		}
		for(i=0;i<n;i++){
			for(j=1;j<n;j++){
				if(number[i]==number[i+j]){
					sum[i]+=sum[i+j];
				}
			}
		}
		for(i=0;i<n;i++){
			if(sum[i]>=1000000){
				harasyo[i]=number[i];
				flag=1;
			}
		}
		if(flag==0){
			printf("NA\n");
		}
			for(i=0;i<=4000;i++){
				if(harasyo[i]!=0){
				printf("%d\n",harasyo[i]);
				
			}
		}
	}
	return 0;
}