#include <iostream>
using namespace std;

int main()
{

  unsigned long f=0;
  unsigned long x, y, z, i=0;
  unsigned long a[4010];
  unsigned long b[4010];
  unsigned long c[4010];
  unsigned long s[4010];
 
  while(1){
    z=0;
    cin>>x;
    if(x==0)
      break;
    
    for(y=0; y<x; y++)
      cin>>a[y]>>b[y]>>c[y];

    for(y=0; y<x; y++)
	s[y]=a[y];

    for(y=0; y<x-1; y++)
      for(i=y+1; i<x; i++)
	if(a[y]==s[i]){
	  b[y]+=b[i];
	  c[y]+=c[i];
	  b[i]=0;
	  c[i]=0;
	}

    for(y=0; y<x; y++){
      if(1000000<=b[y]*c[y]){
	z++;
	cout<<a[y]<<endl;
      }
    }
      
    
    if(z==0)
      cout<<"NA"<<endl;

  }

  return 0;
}