#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
typedef long long ll;
int main(){
  int n,index[10000],inindex,val,num,couter;
  map<int,ll> List;
  while(true){
    scanf("%d",&n);
    if(n == 0)break;
    couter=0;
    List.clear();
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&inindex,&val,&num);
      if(List[inindex] == 0){
	index[couter]=inindex;
	couter++;
      }
      List[inindex]+=val*num;
    }
    int NAf=true;
    for(int i=0;i<couter;i++){
      if(List[index[i]] >= 1000000){
	printf("%d\n",index[i]);
	NAf=false;
      }
    }
    if(NAf)printf("NA\n");
  }

  return 0;
}