#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, num, p, m, j;
  bool t;
  while (cin >> n, n) {
    vector<pair<int, long long int> > V;
    for (int i = 0; i < n; i++) {
      cin >> num >> p >> m;
      t = true;
      for (j = 0; j < V.size(); j++) {
        if (V[j].first == num) {
          t = false;
          break;
        }
      }
      if (t)
        V.push_back(pair<int, long long int>(num, p * m));
      else {
        if (V[j].second < 1000000) V[j].second += p * m;
      }
    }
    t = false;
    for (int i = 0; i < V.size(); i++) {
      if (V[i].second >= 1000000) {
        cout << V[i].first << endl;
        t = true;
      }
    }
    if (!t) cout << "NA" << endl;
  }
}
