#include <bits/stdc++.h>
using namespace std;
int n;
long long id[4000];
long long value[4000];
long long number[4000];
map<long long, long long> total;
int main() {
  cin >> n;
  if (n == 0) {
    return 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> id[i] >> value[i] >> number[i];
    total[id[i]] += value[i] * number[i];
  }
  vector<long long> v;
  if (!total.empty()) {
    map<long long, long long>::iterator it = total.begin();
    while (it != total.end()) {
      if ((*it).second >= 1000000) {
        v.push_back((*it).first);
      }
      ++it;
    }
  }
  if (v.empty()) {
    cout << "NA" << endl;
    return 0;
  }
  for (vector<long long>::iterator it = v.begin(); it != v.end(); ++it) {
    cout << *it << endl;
  }
}
