#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
static const int M = 1000000;

int main()
{
  int N;
  while (cin >> N && N != 0) {
    map<int,pair<int,int> > m;
    vector<pair<int,int> > ans;
    for (int i = 0; i < N; i++) {
      int id, sell, cnt;
      cin >> id >> sell >> cnt;
      const long long n = static_cast<long long>(sell) * cnt;
      map<int,pair<int,int> >::iterator it = m.find(id);
      if (it == m.end()) {
        if (n >= static_cast<long long>(M)) {
          ans.push_back(make_pair(i, id));
          m.insert(make_pair(id, make_pair(i, M)));
        } else {
          m.insert(make_pair(id, make_pair(i, n)));
        }
      } else if (it->second.second < M) {
        if (n >= static_cast<long long>(M)) {
          ans.push_back(make_pair(it->second.first, it->first));
          it->second.second = M;
        } else {
          it->second.second += n;
          if (it->second.second > M) {
            ans.push_back(make_pair(it->second.first, it->first));
          }
        }
      }
    }
    if (ans.empty()) {
      cout << "NA" << endl;
    } else {
      sort(ans.begin(), ans.end());
      for (vector<pair<int,int> >::const_iterator it(ans.begin()); it != ans.end(); ++it) {
        cout << it->second << endl;
      }
    }
  }
  return 0;
}