#include <iostream>
#include <map>

using namespace std;

#define ll long long

int main(void){
  map<int,ll> m;
  int n;
  int no,amount,price;

  while(cin >> n){
	bool exist = false;
        if(!n) break;
	for(int i=0;i<n;i++){
	  cin >> no >> amount >> price;
	  m[no] += amount*price;
	}
	map<int,ll>::iterator it = m.begin();
	while(it!=m.end()){
	  if((*it).second >= 1e+6){
		cout << (*it).first << endl;
		exist = true;
	  }
	  ++it;
	}
	if(!exist) cout << "NA" << endl;
	m.clear();
  }
}