//AOJ0100
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
#define __int64 long long 
int main(){
	int n;
	while(cin>>n,n!=0){
vector< pair<int,__int64> >ta;
ta.clear();
for(int i=0;i<n;i++){
int a,b,c;
cin>>a>>b>>c;
bool f=0;
int index=0;
for(int j=0;j<ta.size();j++)if(ta[j].first==a)f=1,index=j;
__int64 bc=b*c;
if(f==0)ta.push_back(pair<int,__int64>(a,bc));
else ta[index].second+=b*c;
}

bool f=0;
//cout<<"size "<<ta.size()<<endl;
for(int i=0;i<ta.size();i++){
	//cout<<ta[i].first<<"   "<<ta[i].second<<endl;
	if(ta[i].second>=1000000){cout<<ta[i].first<<endl;f=1;}
}
	if(!f)cout<<"NA"<<endl;
}
	return 0;
}