#include <iostream>
#include <map>
using namespace std;
int main() {
  int n, e;
  long long int p, q;

  while(cin >> n) {
	if(n == 0) break;
	map<int, long long int> mp;
	map<int, long long int>::iterator itr;

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

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