#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, p, c;
  while (std::cin >> n, n) {
    vector<int> v;
    vector<int>::iterator it;
    for (; n; n--) {
      cin >> a >> p >> c;
      it = find(v.begin(), v.end(), a);
      if (p * c >= 1000000 && it == v.end()) v.push_back(a);
    }
    if (v.empty())
      cout << "NA" << endl;
    else {
      it = v.begin();
      while (it != v.end()) {
        cout << *it << endl;
        it++;
      }
    }
  }
}
