#include<iostream>
using namespace std;

int main(){
	int n;
	int p[4000];
	int count;
	
	while(cin>>n,n){
		for(int i=0;i<4000;++i)p[i]=0;
		
		for(int i=0;i<n;++i){
			int wn,va,cn;
			cin>>wn>>va>>cn;
			p[wn-1] += va*cn;
		}
		count = 0;
		for(int i=0;i<4000;++i){
			if(p[i] >= 1000000){cout<<i+1<<endl;count++;}
		}
		if(!count)cout<<"NA"<<endl;
		
		
		
		
		
	}
	
	
	
}