#include <iostream>
#include <string>
#include <algorithm>
#define N 4001
using namespace std;
int main(){

  int n,a,b,tanka,uriage,jun[N];
  long long int num[N];
  bool judge;

  while(cin >> n){
    if(n==0)
      break;

    for(int i=0;i<N;i++){
      num[i] = 0;
      jun[i] = 0;
    }

    for(int i=0,b=0;i<n;i++){
      judge = true;
      cin >> a >> tanka >> uriage;
      num[a] += tanka * uriage;
      for(int j=0;j<i;j++){
	if(jun[j]==a){
	  judge = false;
	  break;
	}
      }
      if(judge){
	jun[b] = a;
	b++;
      }
    }

    judge = true;
    for(a=0;jun[a]!=0;a++){
      if(num[jun[a]]>=1000000){
	cout << jun[a] << endl;
	judge = false;
      }
    }
    if(judge)
      cout << "NA" << endl;
  }
  return 0;
}