#include <stdio.h>

int main(void)
{

	int n, a, b, No,data[4000];

	while(scanf("%d", &n), n != 0){
		bool check = false;
		for(int i = 0; i < 4000; i++)
			data[i] = 0;
		for(int i = 0; i < n; i++){
			scanf("%d %d %d", &No, &a, &b);
			data[No-1] += a*b;
			if(data[No-1] >= 1000000){
				printf("%d\n", No);
				data[No-1] = -1000000000;
				check = true;
			}
		}
		if(!check)
			printf("NA\n");

	}


	return 0;
}