#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long int lli;

const lli kSum = 1000000;

lli getSum(int price, int sales)
{
  return price * sales;
}

int main()
{
  int n_employee;
  int number;
  lli price, sales;
  bool flag;
  map<int, lli> checkEmp;
  vector<int> empNumbers;

  while(cin >> n_employee){
    if(n_employee == 0){
      break;
    }

    flag = true;

    for(int i = 0; i < n_employee; ++i){
      cin >> number >> price >> sales;

      if(checkEmp.find(number) != checkEmp.end()){
	checkEmp[number] += getSum(price, sales);
      } else {
	checkEmp[number] = getSum(price, sales);
	empNumbers.push_back(number);
      }
    }

    int length = empNumbers.size();
    for(int i = 0; i < length; ++i){
      if(checkEmp[empNumbers[i]] >= kSum){
	cout << empNumbers[i] << endl;
	flag = false;
      }
    }

    if(flag){
      cout << "NA" << endl;
    }
    checkEmp.clear();
  }

  return 0;
}