#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    vector<int> ans;
    long long int e, p, m;
    for (int i = 0; i < n; i++) {
      cin >> e >> p >> m;
      if (p * m >= 1000000) {
        bool b = true;
        auto it = ans.begin();
        while (it != ans.end()) {
          if (*it == e) b = false;
          ;
          it++;
        }
        if (b) ans.push_back(e);
      }
    }
    if (ans.empty()) {
      cout << "NA" << endl;
    } else {
      auto it = ans.begin();
      while (it != ans.end()) {
        cout << *it << endl;
        it++;
      }
    }
  }
}
