#include<bits/stdc++.h>
using namespace std;

int main(){

  int n;

  while(cin>>n,n){

	long long e,p,q;
	map<long long,long long> total;
	bool flag = false;

	for(int i=0;i<n;++i){
	  cin>>e>>p>>q;

	  if(total[e] <1000000){
		total[e]+=p*q;
		if(total[e] >= 1000000){
		  cout<<e<<endl;
		  flag = true;	  
		}
	  }

	}
	
	if(flag == false)
	  cout<<"NA"<<endl;
	
  }

  return 0;
  
}

