#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct shain{
	int id;
	int uriage;
	struct shain *next;
}shine;

shine *makeNewNode(int id,int tanka,int uriage){
	shine *newNode;
	newNode=(shine *)malloc(sizeof(shine));
	
	newNode->id=id;
	newNode->uriage=uriage*tanka;
	newNode->next=NULL;
	return (newNode);
}

int main(){
	int count=0,counter;
	while(1){
		scanf("%d",&counter);
		if(counter==0){
			break;
		}
		count=0;
		shine *newNode;
		shine *nowNode;
		shine *firstNode=NULL;
		while(counter>count){
			int a,b,c;
			scanf("%d %d %d",&a,&b,&c);
			newNode=makeNewNode(a,b,c);
			if(firstNode==NULL){
				firstNode=newNode;
				nowNode=newNode;
			}else{
				nowNode=firstNode;
				while(nowNode->id!=newNode->id&&nowNode->next!=NULL){
					nowNode=nowNode->next;
				}
				
				if(nowNode->id==newNode->id){
					nowNode->uriage+=newNode->uriage;
				}else{
					nowNode->next=newNode;
				}
			}
			count++;
		}
		nowNode=firstNode;
		int flag=1;
		while(nowNode!=NULL){
			if(nowNode->uriage>=1000000){
				printf("%d\n",nowNode->id);
				flag=0;
			}
			nowNode=nowNode->next;
		}
		if(flag){
			printf("NA\n");
		}
	}
	return 0;
}