#include <stdio.h>


int n;
int num[4000];
int tanka[4000],sale_num[4000];
int sale_all[4001],judge[4000];

int main(void)
{
int i,j,k;
	
while((scanf("%d",&n),n!=0)){
	for(i=0;i<n;i++){
		scanf("%d %d %d",&num[i],&tanka[i],&sale_num[i]);
		sale_all[num[i]]=0;
	}
	k=0;
	for(j=0;j<4001;j++)	judge[j]=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;
}