#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n && n) {
    set<string> list;
    string id;
    long long a, b, c = 1000000;
    for (int i = 0; i < n; i++) {
      cin >> id >> a >> b;
      if (a * b >= c && list.find(id) == list.end()) {
        list.insert(id);
        cout << id << endl;
      }
    }
    if (list.size() == 0) cout << "NA" << endl;
  }
}
