#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, i, p, q;
  map<int, long long int> emp;
  vector<int> seq;
  while (cin >> n && n) {
    bool isExist = false;
    emp.clear();
    seq.clear();
    for (int l = 0; l < (n); ++l) {
      cin >> i >> p >> q;
      if (!emp[i]) seq.push_back(i);
      emp[i] += p * q;
    }
    for (int i = 0; i < (seq.size()); ++i) {
      if (emp[seq[i]] >= 1000000) {
        cout << seq[i] << endl;
        isExist = true;
      }
    }
    if (!isExist) cout << "NA" << endl;
  }
}
