#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;
  bool b;
};
int main() {
  int n;
  while (cin >> n, n) {
    vector<salary> vs;
    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, false});
      for (int j = 0; j < (int)(vs.size()); ++j) {
        if (vs[j].sell >= 1000000) {
          vs[j].b = true;
        }
      }
    }
    bool b2 = false;
    for (int i = 0; i < (int)(vs.size()); ++i) {
      if (vs[i].b) {
        cout << vs[i].no << endl;
        b2 = true;
      }
    }
    if (!b2) cout << "NA" << endl;
  }
}
