#include <iostream>
using namespace std;

long long worker[4001];

void init() {
  for(int i = 0; i < 4001; ++i) {
	worker[i] = 0;
  }
}

int main() {
  int n, id, p, q;
  while(cin >> n) {
	if(!n) break;

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

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