#include <iostream>
#include <map>

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		map<int,pair<long long,int> > m; // id,price,appear
		for(int i=0;i<n;i++){
			int id,price,num;
			cin>>id>>price>>num;
			m[id].first+=(long long)price*num;
			if(m[id].second==0)
				m[id].second=i+1;
		}
		
		map<int,int> m2; // first,id
		for(map<int,pair<long long,int> >::iterator i=m.begin();i!=m.end();i++)
			if(i->second.first>=1000000)
				m2[i->second.second]=i->first;
		
		for(map<int,int>::iterator i=m2.begin();i!=m2.end();i++)
			cout<<i->second<<endl;
		if(m2.size()==0)
			cout<<"NA"<<endl;
	}
	
	return 0;
}