#include<cstdio>
#include<cstring>

int main(){
	int total[4000],n,a,b,c;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(total,0,sizeof(total));
		while(n--){
			scanf("%d%d%d",&a,&b,&c);
			total[a-1]=total[a-1]+b*c;
		}
		int res=0;
		for(int i=0;i<4000;i++){
			if(total[i]>=1000000){
				res=1;
				printf("%d\n",i+1);
			}
		}
		if(res) continue;
		else printf("NA\n");
	}
	return 0;
}