#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
ll need = (int)1e6;
ll sum[4040];

int main() {
	while (1) {
		cin >> n; if (n == 0) break;
		
		memset(sum, 0, sizeof(sum));
		for (int i = 0; i < n; i++) {
			int id, q, p; cin >> id >> q >> p;
			sum[id] += q * p;
		}
		
		bool na = true;
		for (int i = 0; i < 4040; i++) {
			if (sum[i] >= need) {
				cout << i << endl;
				na = false;
			}
		}
		
		if (na) cout << "NA" << endl;
	}
	
	return 0;
}