#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    map<int,pair<int,int> > com;
    vector<pair<int,int> > ans;
    int a,b,c,x = 1;
    while(n--){
      cin >>a>>b>>c;
      if(!com[a].first){com[a].first = x++;}
      if(com[a].second+b*c>1000000){com[a].second = 1000000;}
      else{com[a].second+=b*c;}
    }
    map<int,pair<int,int> >::iterator pos;
    for(pos=com.begin(); pos!=com.end(); pos++){
      if(pos->second.second>=1000000){ans.push_back(make_pair(pos->second.first,pos->first));}
    }
    if(ans.empty()){cout <<"NA"<<endl;}
    else{
      sort(ans.begin(),ans.end());
      for(int i=0; i<ans.size(); i++){
	cout <<ans[i].second<<endl;
      }
    }
  }
  return 0;
}