#include<iostream>
#include<vector>

using namespace std;

void Swap(int&, int&);

int main(){
  int i, j, n, id, x, y, sum;
  vector<int> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> id >> x >> y;
      if(x < y) Swap(x, y);

      for(j=0, sum=0; j<y; ++j){
	sum += x;
	if(sum >= 1000000){
	  data.push_back(id);
	  break;
	}
      }
    }

    if(data.size() == 0){
      cout << "NA" << endl;
    }else{
      for(i=0; i<data.size(); ++i)
	cout << data[i] << endl;
    }

    data.clear();
  }
  return 0;
}

void Swap(int& x, int& y){
  int z;
  z = x;
  x = y;
  y = z;
}