//11
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    long long total[4001]={};
    bool out=false;
    for(int i=0;i<n;i++){
      int id;
      long long t,ns;
      cin>>id>>t>>ns;
      if(total[id]<1000000){
	total[id]+=t*ns;
	if(total[id]>=1000000){
	  cout<<id<<endl;
	  out=true;
	}
      }
    }
    if(!out){
      cout<<"NA"<<endl;
    }
  }
  return 0;
}