#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,num,mon,cont,a[4000],nacount;
  while(scanf("%d",&n)!=EOF){
    if(n==0){break;}
    for(int i=0;i<4000;i++){
      a[i]=0;
    }
    nacount=0;
    for(int i=0;i<n;i++){
      cin>>num>>mon>>cont;
      a[num]+=mon*cont;
    }
    for(int i=0;i<3999;i++){
      if(a[i]>=1000000){
	cout<<i<<endl;
	nacount++;
      }
    }if(nacount==0){
      cout<<"NA"<<endl;
    }
  }
  return 0;
}