#include <stdio.h>

#define EMPLOYEESIZE 4000

int main()
{
	int n, i;
	double saleResults[EMPLOYEESIZE], employeeID[EMPLOYEESIZE];
	int id;
	double p, q;
	int isOk;

	scanf("%d", &n);
	while ( n != 0 ) {
		isOk = 0;
		memset(saleResults, 0, sizeof(saleResults));
		memset(employeeID, 0, sizeof(employeeID));

		for ( i = 0; i < n; i++ ) {
			scanf("%d %lf %lf", &id, &p, &q);
			saleResults[id] += p * q;
			employeeID[id] = 1;
		}

		for ( i = 0; i < EMPLOYEESIZE; i++ ) {
			if ( employeeID[i] == 1 && saleResults[i] >= 1000000 ) {
				printf("%d\n", i);
				isOk = 1;
			}
		}
		if ( !isOk ) printf("NA\n");

		scanf("%d", &n);
	}

	return 0;
}