#include<cstdio>
#include<cstring>

int main(){
	int total[4000],n,a,b,c;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		while(n--){
			memset(total,0,sizeof(total));
			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++;
			}
		}
		if(res)printf("%d\n",res);
		else printf("NA\n");
	}
}