#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c;
  vector<long long> g;
  while (cin >> n && n) {
    g.clear();
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      if (b > 10000 && c > 10000)
        g.push_back(a);
      else if (b * c >= 1000000)
        g.push_back(a);
    }
    if (!g.size()) cout << "NA" << endl;
    for (int i = 0; i < g.size(); i++) {
      cout << g[i] << endl;
    }
  }
}
