#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;
    set<int> si;
    for (int i = 0; i < (int)(n); ++i) {
      int no, v, sum;
      cin >> no >> v >> sum;
      if (si.find(no) == si.end()) {
        vs.push_back({no, (long long)(v * sum)});
        si.insert(no);
      } else
        for (int j = 0; j < (int)(vs.size()); ++j) {
          if (vs[j].no == no) vs[j].sell += (long long)(v * sum);
        }
    }
    bool b = false;
    for (int j = 0; j < (int)(vs.size()); ++j) {
      if (vs[j].sell >= 1000000) {
        cout << vs[j].no << endl;
        b = true;
      }
    }
    if (!b) cout << "NA" << endl;
  }
}
