#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
int main(){
int n;
while(cin>>n,n){
long ta[5000]={0};int x[5000]={0};
int cnt=0,a,b,c;
	for(int i=0;i<n;i++){
	cin>>a>>b>>c;
	ta[a]+=b*c;
	bool f=1;
	for(int j=0;j<i;j++)if(x[j]==a)f=0;
	if(f)x[cnt++]=a;
	}
	bool f=1;
	for(int i=0;i<n;i++){
	//cout<<x[i]<<" "<<ta[x[i]]<<endl;
	if(ta[x[i]]>=1000000){cout<<x[i]<<endl;f=0;}
	}
	if(f)cout<<"NA"<<endl;
}
	return 0;
}