#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
ll need = 1000000;

int main() {
	while (1) {
		cin >> n; if (n == 0) break;
		
		map<ll, ll> sum;
		set<ll> ids;
		for (int i = 0; i < n; i++) {
			ll id, p, q; cin >> id >> p >> q;
			ids.insert(id);
			sum[id] += (p * q);
		}
		
		bool na = true;
		set<ll>::iterator it;
		for (it = ids.begin(); it != ids.end(); it++) {
			if (sum[(*it)] >= need) {
				cout << (*it) << endl;
				na = false;
			}
		}
		
		if (na) cout << "NA" << endl;
	}
	
	return 0;
}