#include <stdio.h>

int main(void)
{

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

	while(scanf("%d", &n), n != 0){
		bool check = false;
		c = 0;
		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){
				d[c] = No;
				c++;
				data[No-1] = -1000000000;
				check = true;
			}
		}
		if(!check)
			printf("NA\n");
		else
			for(int i = 0; i < c; i++)
				printf("%d\n", d[i]);

	}


	return 0;
}