#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n;
  while(cin >> n, n){
    map<ll, ll> info;
    for(int i = 0; i < n; i++){
      int id, x, y;
      cin >> id >> x >> y;
      info[id] += x*y;
    }
    bool isAns = false;
    for(map<ll,ll>::iterator it = info.begin(); it != info.end(); it++){
      if(it->second >= 1000000){
	isAns = true;
	cout << it->first << endl;
      }
    }
    if(!isAns)cout << "NA" << endl;
  }
  return 0;
}