#include<iostream>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
	int N;
	
	while(cin>>N,N){
		map<int,long long int> mp,mp2;
		vector <int> vi;
		priority_queue<int, vector<int>, greater<int> >pq;
		for(int i=0;i<N;i++){
			int num,tanka,suuryo;
			cin>>num>>tanka>>suuryo;
			mp[num]+=tanka*suuryo;
			vi.push_back(num);
			if(mp[num]>=1000000){
				mp2[num]++;
			}
		}
		vector<int>::iterator it=vi.begin();
		for(;it!=vi.end();it++){
                        int a=*it;
			if(mp2[a]>=2){
				mp2[a]--;
			}
			else if(mp2[a]==1){
				pq.push(a);
				mp2[a]--;
			}
		}
		if(pq.empty()){
			cout<<"NA"<<endl;
		}
		else{
			int len=pq.size();
			for(int i=0;i<len;i++){
				cout<<pq.top()<<endl;
				pq.pop();
			}
		}
	}
	return 0;
}