#include <stdio.h>

typedef struct shain{
	int bangou;
	int uriage;
}shain;

int main(void){
	int data_n,i,j,flag,kaburi,hyouji;
	int bangou,tanka,suuryou;
	shain men[4001];
	
	while(1){
		scanf("%d",&data_n);
		if(data_n == 0) break;
		kaburi = 0;
		hyouji = 0;
		for(i=0;i < 4001;i++){
			men[i].bangou = 0;
			men[i].uriage = 0;
		}
		for(i=0;i < data_n;i++){
			scanf("%d %d %d",&bangou,&tanka,&suuryou);
			for(j=0;j <= i;j++){
				if(men[j].bangou == bangou){
					flag = 1;
					kaburi++;
					men[j].uriage += tanka*suuryou;
				}
			}
			if(flag != 1){
				men[i].bangou = bangou;
				men[i].uriage = tanka*suuryou;
			}
			flag = 0;
		}
		j = i;
		for(i=0;i < j;i++){
			if(men[i].uriage >= 1000000){
				printf("%d\n",men[i].bangou);
				hyouji++;
			}
		}
		if(hyouji == 0) printf("NA\n");
	}
	return 0;
}