#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){	
	int n;
	while(cin>>n){
	      if(n==0) break;
	      vector<int> a;
	      vector<long long> b;
	      vector<long long> c;
	      int x,y,z;
	      map <int,long long> sum;
	      for(int i=0;i<n;i++){
		cin>>x>>y>>z;
		a.push_back(x);
		b.push_back(y);
		c.push_back(z);
		sum[x]+=y*z;
	       }
	       int cnt=0;
	       for(int i=0;i<n;i++){
                     if(sum[a[i]]>=1000000){
			   int cnt2=0;
                           for(int j=0;j<i;j++){
				if(a[i]==a[j]) cnt2++;break;}
                            if(cnt2>0) continue;
                            else{   
				cout<<a[i]<<endl;
				cnt++;}
		     }
		}
		if(cnt==0) cout<<"NA"<<endl;
	}
	return 0;
}