#include<iostream>
#include<queue>
#include<map>
using namespace std;
main(){
  long long a,b,c,n,f;
  while(cin>>n,n){
		map<int,long long> m;
		queue<int> v;
		f=1;
    for(;n;n--){
			cin>>a>>b>>c;
      if(!m[a])v.push(a);
      m[a] += b*c;
    }
    
    while(v.size())
			if(m[v.front()]>999999)f=0,cout<<v.pop()<<endl;
    if(f)cout<<"NA"<<endl;
  }
}