#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n != 0) {
    vector<pair<int, int> > v(n);
    int num = 0;
    for (int i = 0; i < n; ++i) {
      int id, p, q;
      cin >> id >> p >> q;
      v[i] = make_pair(id, p * q);
    }
    sort(v.begin(), v.end());
    int sum = v[0].second;
    for (int i = 1; i < n; i++) {
      if (v[i].first == v[i - 1].first) {
        if (i + 1 != n) {
          sum += v[i].second;
        } else {
          sum += v[i].second;
          if (sum >= 1000000) {
            cout << v[i].first << endl;
            num++;
          }
        }
      } else {
        if (sum >= 1000000) {
          cout << v[i - 1].first << endl;
          num++;
        }
        sum = v[i].second;
        if (sum >= 1000000) {
          cout << v[i].first << endl;
          num++;
        }
      }
    }
    if (num == 0) {
      cout << "NA" << endl;
    }
    cin >> n;
  }
  return 0;
}
