#include <iostream>
using namespace std;
typedef long long ll;

ll worker[4001];

int main() {
  int n, id;
  long long p, q;
  while(cin >> n && n) {

	fill((ll*)worker, (ll*)(worker + 4001), 0);
	for(int i = 0; i < n; ++i) {
	  cin >> id >> p >> q;
	  worker[id] += p * q;
	}

	bool isNA = 1;
	for(int i = 1; i < 4001; ++i) {
	  if(worker[i] >= 1000000) {
		cout << i << endl;
		isNA = 0;
	  }
	  /*
	  if(worker[i] != 0) {
		cout << "i:" << i << " result:" << worker[i] << endl;;
		isNA = 0;
	  }
	  */
	}
	
	if(isNA) {
	  cout << "NA" << endl;
	}
	
  }
  return 0;
}