#include<iostream>
using namespace std;
main(){
	int n;
	while(cin>>n,n){
		int c=0,data[4000+1],no[n];
		for(int i=0;i<=4000;++i)data[i]=0;
		for(int i=0;i<n;++i){
			no[i]=0;
			int n2,tan,num;
			cin>>n2>>tan>>num;
			if(!data[n2])no[i]=n2;
			data[n2]+=tan*num;
		}
		for(int i=0;i<n;++i){
			int n2=no[i];
			if(data[n2]>=1000000){
				cout<<n2<<endl;
				c++;
			}
		}
		if(!c)cout<<"NA"<<endl;
	}
}