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

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

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

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

    for(int i=0;i<n;i++){
      cin >> a >> tanka >> uriage;
      num[a] += tanka * uriage;
    }

    for(int i=1;i<N;i++){
      if(num[i]>=1000000){
	cout << i << endl;
	judge = false;
      }
    }
    if(judge)
      cout << "NA" << endl;
  }
  return 0;
}