#include<iostream>
#include<map>
#include<vector>
using namespace std;

typedef long long ll;

#define BORDER 1000000LL

int main() {
	map<int, ll> dat;
	vector<int> ord;
	int n, id, c; ll e, s;
	while(1) {
		cin >> n;
		if(!n) break;
		dat.clear(); ord.clear();
		for(int i=0; i<n; ++i) {
			cin >> id >> e >> s;
			if(!dat.count(id)) {
				ord.push_back(id);
				dat[id] = e*s;
			}else dat[id] += e*s;
		}
		c = 0;
		for(int i=0; i<(signed)ord.size(); ++i) {
			id = ord[i];
			if(dat[id]>=BORDER) {
				cout << ord[i] << endl;
				++c;
			}
		}
		if(!c) cout << "NA" << endl;
	}
	return 0;
}