#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;
		rep(i, n) {
			ll e, p, q; cin >> e >> p >> q;
			mp[e] += p*q;
		}
		bool flag = false;
		for (auto i : mp) {
			if (i.second >= 1000000) {
				flag = true;
				cout << i.first << endl;
			}
		}
		if (!flag)puts("NA");
	}
}