#include <iostream>
//#include <cstdio>
#include <map>
using namespace std;
int main() {
  int n;
  while(cin >> n) {
	if(n == 0) break;
	int e, p, q;
	map<int, long> mp;
	map<int, long>::iterator itr;

	for(int i = 0; i < n; ++i) {
	  cin >> e >> p >> q;
	  itr = mp.find(e);
	  if(itr == mp.end()) {// not found
		mp[e] = p * q;
	  }
	  else {// found
		itr->second += p * q;
	  }
	}
	
	/*
	puts("======================");
	puts("ID\tprofit");
	for(itr = mp.begin(); itr != mp.end(); ++itr) {
	  printf("%d\t%ld\n", itr->first, itr->second);
	}
	puts("======================");
	*/
	
	bool isNA = 1;
	for(itr = mp.begin(); itr != mp.end(); ++itr) {
	  if(itr->second >= 1000000) {
		cout << itr->first << endl;
		isNA = 0;
	  }
	}
	if(isNA) {
	  cout << "NA" << endl;
	}
  }
  return 0;
}