#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
	int n,num,price,amount;
	while(cin>>n&&n){
		map<int,long long> m;
		vector<int> v;
		while(n--){
			cin>>num>>price>>amount;
			long long sum = (long long)price*amount;
			if(m.find(num)!=m.end()) m[num]+=sum;
			else m[num]=sum;
		}
		for(map<int,long long>::iterator it=m.begin();it!=m.end();++it){
			if((*it).second>=1000000) v.push_back((*it).first);
		}
		if(v.size()!=0) for(int i=0;i<v.size();++i)cout<<v[i]<<"\n";
		else cout<<"NA\n";
	}
	return 0;
}