#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
	int n;
	int e[1000];
	int p[1000];
	int q[1000];
	int total[1000];
	cin >> n;
	while (n!=0){
		e[1000] = { 0 };
		p[1000] = { 0 };
		q[1000] = { 0 };
		total[1000] = { 0 };
		for (int i = 0; i < n; i++) {
			cin >> e[i] >> p[i] >> q[i];
			total[i] = p[i] * q[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i != j && e[i] == e[j]) {
					total[i] += total[j];
					total[j] = 0;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (total[i] >= 1000000)printf("%d\n", e[i]);
			else printf("NA\n");
		}
		cin >> n;
	}
	return 0;
}
