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

ll worker[4001];

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

	worker[4001] = {0};
	for(int i = 0; i < n; ++i) {
	  cin >> id >> p >> q;
	  if(worker[id] < 1000000 && worker[id] + p*q >= 1000000) {
		cout << id << endl;
		isNA = 0;
	  }
	  worker[id] += p * q;
	}
  }
  
  if(isNA) {
	cout << "NA" << endl;
  }

  return 0;
}