#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int id, price, amount;
  vector<int> rank;
  map<int, long long> ids;
  bool exist;
  while (cin >> n && n) {
    exist = false;
    rank.clear();
    ids.clear();
    for (int i = 0; i < n; ++i) {
      cin >> id >> price >> amount;
      if (!ids[id]) rank.push_back(id);
      ids[id] += price * amount;
    }
    for (int i = 0; i < rank.size(); ++i) {
      if (ids[rank[i]] >= 1000000) {
        exist = true;
        cout << rank[i] << endl;
      }
    }
    if (!exist) cout << "NA" << endl;
  }
}
