#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
struct salary {
  int no;
  long long sell;
};
int main() {
  int n;
  while (cin >> n, n) {
    vector<salary> vs;
    vector<int> vector<int>;
    for (int i = 0; i < (int)(n); ++i) {
      int no, sell_n, value;
      cin >> no >> sell_n >> value;
      bool b = false;
      for (int j = 0; j < (int)(vs.size()); ++j) {
        if (vs[j].no == no) {
          b = true;
          vs[j].sell += sell_n * value;
        }
      }
      if (!b) vs.push_back({no, sell_n * value});
      for (int j = 0; j < (int)(vs.size()); ++j) {
        if (vs[j].sell >= 1000000) {
          if (find(vector<int>.begin(), vector<int>.end(), vs[j].no) ==
              vector<int>.end())
            vector<int>.push_back(vs[j].no);
        }
      }
    }
    for (int i = 0; i < (int)(vector<int>.size()); ++i) {
      cout << vector<int>[i] << endl;
    }
    if (vector<int>.size() == 0) cout << "NA" << endl;
  }
}
