#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    vector<pair<int, long long int> > v;
    for (int i = 0; i < n; i++) {
      int place = -1;
      int p, q, r;
      cin >> p >> q >> r;
      bool isExist = false;
      for (int i = 0; i < v.size(); i++) {
        if (v[i].first == p) {
          isExist = true;
          place = i;
        }
      }
      if (!isExist)
        v.push_back(make_pair(p, q * r));
      else {
        v[place].second += q * r;
      }
    }
    bool isExist = false;
    for (int i = 0; i < v.size(); i++) {
      if (1000000 <= v[i].second) {
        isExist = true;
        cout << v[i].first << endl;
      }
    }
    if (!isExist) cout << "NA" << endl;
  }
}
