#include <iostream>
#include <string>
using namespace std;

#define N 4000

int main(void) {
	int shine[N+1];
	bool shinef[N+1];
	bool na;
	int n,a,b,c;

	while (cin >> n, n) {
		na = true;
		for (int i = 0; i < N; i++) {
			shine[i] = 0;
			shinef[i] = false;
		}
		while (n--) {
			cin >> a >> b >> c;
			shine[a] += c*b;
			if (shine[a] >= 1000000 && shinef[a] == false) {
				cout << a << endl;
				shinef[a] = true;
				na = false;
			}
		}
		if (na) cout << "NA" << endl;
	}
	return 0;
}