#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    if (!n) {
      break;
    }
    deque<int> x;
    for (int i = 0; i < n; i++) {
      int num, v, q;
      cin >> num >> v >> q;
      if (v * q >= 1000000) {
        int f = 0;
        for (int j = 0; j < x.size(); j++) {
          if (x[j] == num) {
            f = 1;
            break;
          }
        }
        if (!f) {
          x.push_back(num);
        }
      }
    }
    if (x.empty()) {
      cout << "NA" << endl;
    } else {
      for (int i = 0; i < x.size(); i++) {
        cout << x[i] << endl;
      }
    }
  }
  return 0;
}
