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

#define EMPLOYEESIZE 4000

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

	while (1) {
		scanf("%d", &n);
		if ( n == 0 ) {
			break;
		} else {
			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");
		}
	}

	return 0;
}