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