#include <iostream>
#include <map>
using namespace std;
int main() {
  int n;
  map<int, long> mp;
  map<int, long>::iterator itr;

  while(cin >> n) {
	if(n == 0) break;
	int e, p, q;

	for(int i = 0; i < n; ++i) {
	  cin >> e >> p >> q;
	  itr = mp.find(e);
	  if(itr == mp.end()) {// not found
		mp[e] = int(p * q);
	  }
	  else {
		itr->second += p * q;
		if(itr->second >= 1000000) {
		  itr->second = -1;
		}
	  }
	}

	bool isNA = true;
	for(itr = mp.begin(); itr != mp.end(); ++itr) {
	  if(itr->second -1) {
		cout << itr->first << endl;
		isNA = false;
	  }
	}
	if(isNA) {
	  cout << "NA" << endl;
	}

	mp.clear();
  }
  return 0;
}