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

int main(void)
{
	int n, i, buf[3], *idlist, index_idlist = 0, milcount = 0;
	unsigned long long int *sale;

	scanf("%d", &n);

	sale = (unsigned long long int *)calloc(4000, sizeof(unsigned long long int));
	idlist = (int *)calloc(n, sizeof(int));

	while (n != 0){
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &buf[0], &buf[1], &buf[2]);
			sale[buf[0] - 1] += buf[1] * buf[2];
			idlist[index_idlist++] = buf[0];
		}

		for (i = 0; i < n; i++){
			if (sale[idlist[index_idlist]] >= 1000000){
				printf("%d\n", idlist[index_idlist]);
				sale[idlist[index_idlist--]] = 0;
			}
			milcount++;
		}

		if (milcount == 0){
			puts("NA");
		}
		milcount = 0;
		scanf("%d", &n);
	}
	return 0;
}