#include<stdio.h>
int main(void)
{
	int ct,num[4001],tanka[4001],kosu[4001],many[4001];
	while(scanf("%d",&ct)){
		if(ct==0){
			return 0;
		}
		for(int f1=0;f1<ct;f1++){
			scanf("%d %d %d",&num[f1],&tanka[f1],&kosu[f1]);
			many[f1]=tanka[f1]*kosu[f1];
		}
		for(int f1=0;f1<ct;f1++){
			for(int f2=0;f2<ct;f2++){
				if((num[f1]==num[f2])&&f1!=f2){
					many[f1]=many[f1]+many[f2];
					num[f2]=-1;
				}
			}
		}
		int flg=0;
		for(int f1=0;f1<ct;f1++){
			if(many[f1]>=1000000){
				printf("%d\n",num[f1]);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}