#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main() {
	ll n;
	while (cin >> n, n) {
		map<ll, ll>mp;
		vector<ll>v;
		rep(i, n) {
			ll e, p, q; cin >> e >> p >> q;
			mp[e] += p*q;
			if (!binary_search(v.begin(), v.end(), e))
				v.push_back(e);
		}
		bool flag = false;
		for (ll i : v) {
			if (mp[i] >= 1000000) {
				cout << i << endl;
				flag = true;
			}
		}
		if (!flag)puts("NA");
	}
}