#include <cstdio.h>
using namespace std;

int main() {
	int tmp=0, tmpi=0, tmpp=0, tmpq=0, n=1, tmpn=0, ans0=0;
	long long int ans[4001];
	while (1) {
		ans0=0;
		scanf("%d", &n);
		if (n==0) break;
		for (tmp=0;tmp<4001;tmp++) ans[tmp]=0;
		for (tmpn=0;tmpn<n;tmpn++) {
			scanf("%d %d %d", &tmpi, &tmpp, &tmpq);
			ans[tmpi]+=(long long int)tmpp*tmpq;
		}
		for (tmp=0;tmp<4001;tmp++) {
			if (ans[tmp]>=1000000) {
				ans0++;
				printf("%d\n", tmp);
			}
		}
		if (ans0==0) puts("NA");
	}
	return 0;
}