#include <bits/stdc++.h>
using namespace std;
const int kSum = 1000000;
int getSum(int price, int sales) { return price * sales; }
int main() {
  int n_employee;
  int number, price, sales;
  bool flag;
  map<int, int> checkEmp;
  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);
      }
    }
    for (map<int, int>::iterator iter = checkEmp.begin();
         iter != checkEmp.end(); ++iter) {
      if (iter->second >= kSum) {
        cout << iter->first << endl;
        flag = false;
      }
    }
    if (flag) {
      cout << "NA" << endl;
    }
    checkEmp.clear();
  }
  return 0;
}
