#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, p, q;
  while (true) {
    cin >> n;
    if (n == 0) break;
    map<int, int> mop;
    vector<int> ord;
    bool check = true;
    for (int j = 0; j < n; j++) {
      cin >> i >> p >> q;
      if (mop.find(i) == mop.end()) {
        mop[i] = p * q;
        ord.push_back(i);
      } else if (mop[i] < 1000000) {
        mop[i] += p * q;
      }
    }
    for (int j = 0; j < ord.size(); j++) {
      if (mop[ord[j]] >= 1000000) {
        cout << ord[j] << endl;
        check = false;
      }
    }
    if (check) cout << "NA\n";
  }
  return 0;
}
