#include<stdio.h>
#include<string.h>
#define Max(x,y) ((x>y)?x:y)
#define min(x,y) ((x<y)?x:y)
#define L 1000000
int m[4005];
int main(){
	int i,j,n,a,b,c,f;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		f=0;
		memset(m,0,sizeof(m));
		while(n--){
			scanf("%d%d%d",&a,&b,&c);
			if(m[a]>=0){
				if(b!=0 && (L-m[a])/b<=c){
					printf("%d\n",a);
					m[a]=-1;
					f=1;
				}else m[a]+=b*c;
			}
		}
		if(f==0)printf("NA\n");
	}
	return 0;
}