#include<stdio.h>
#include<list>
class hoge{
 public:
  int num;
  long long int v;
  hoge(int n,int va){
    num=n;
    v=va;
  }
};


int main(){
  using namespace std;
  int i,n,v,c,num,flg;
  long long int a;
  list<hoge> ls;
  list<hoge>::iterator pos;
  do{
    scanf("%d",&n);
    if(!n) break;
    for(i=0;i<n;i++){
      scanf("%d %d %d",&num,&v,&c);
      pos=ls.begin();
      while(pos!=ls.end()){
	if((*pos).num==num){
	  (*pos).v+=v*c;
	  break;
	}
	pos++;
      }
      if(pos==ls.end()){
	pos=ls.begin();
	while(pos!=ls.end()){
	  if((*pos).num>num){
	    a=v;
	    a*=c;
	    ls.insert(pos,*(new hoge(num,a)));
	    break;
	  }
	  pos++;
	}
	if(pos==ls.end()){
	  a=v;
	  a*=c;
	  ls.push_back(*(new hoge(num,a)));
	}
      }
    }
    pos=ls.begin();
    flg=1;
    while(pos!=ls.end()){
      if((*pos).v>=1000000){
	printf("%d\n",(*pos).num);
	flg=0;
      }
      pos++;
    }
    if(flg) printf("NA\n");
    ls.clear();
  }while(1);
  return 0;
}