#include <cstdio>
#include <cstring>

using namespace std;

int main(void){
	int n, id, value, num, i;
	long long int yen[4000];
	bool f;
	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}
		memset(yen,0ll,sizeof(yen));
		for(i = 0;i < n;i++){
			scanf("%d%d%d",&id,&value,&num);
			yen[id - 1] += (long long int)value * num;
		}
		f = true;
		for(i = 0;i < 4000;i++){
			if(yen[i] >= 1000000ll){
				printf("%d\n",i + 1);
				f = false;
			}
		}
		if(f){
			printf("NA\n");
		}
	}
	return 0;
}