#include <bits/stdc++.h>
using namespace std;
int main() {
  array<long long, 4000> ar;
  vector<long long> ans;
  long long n;
  int e, p, q;
  while (true) {
    cin >> n;
    ar.fill(0);
    if (!n) {
      break;
    }
    bool isNA = true;
    for (int i = 0; i < n; ++i) {
      cin >> e >> p >> q;
      ar[e] += p * q;
    }
    for (int i = 0; i < 4000; ++i) {
      if (ar[i] >= 1000000) {
        auto it = ans.begin();
        it = std::find(it, ans.end(), i);
        if (it == ans.end()) {
          ans.push_back(i);
        }
        isNA = false;
      }
    }
    if (isNA) {
      ans.push_back(-1);
    }
  }
  for (auto it : ans) {
    if (it != -1) {
      cout << it << endl;
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}
