#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, num, tanka, count, i;
  map<int, pair<int, long long> > mipii;
  while (cin >> n, n) {
    mipii.clear();
    for (i = 0; i < n; i++) {
      cin >> num >> tanka >> count;
      if (mipii.count(num) == 0) {
        mipii[num] = make_pair(i, (long long)tanka * (long long)count);
      } else {
        pair<int, long long> tmp = mipii[num];
        tmp.second = max(tmp.second, (long long)tanka * (long long)count);
        mipii[num] = tmp;
      }
    }
    vector<pair<int, int> > vp;
    for (typeof(mipii.begin()) it = mipii.begin(); it != mipii.end(); it++) {
      if (it->second.second >= 1000000) {
        vp.push_back(make_pair(it->second.first, it->first));
      }
    }
    sort(vp.begin(), vp.end());
    if (vp.size() == 0) {
      puts("NA");
    } else {
      for (i = 0; i < vp.size(); i++) {
        printf("%d\n", vp[i].second);
      }
    }
  }
  return 0;
}
