#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 c = 1;
    for (int i = 0; i < n - 1; ++i) {
      if (v[i].first != v[i + 1].first) {
        c++;
      }
    }
    vector<pair<int, int> > sum(c);
    int k = 0;
    for (int i = 0; i < c; ++i) {
      sum[i] = make_pair(0, 0);
    }
    int s = 0;
    for (int i = 0; i < n; ++i) {
      s += v[i].second;
      if (i < n - 1) {
        if (v[i].first != v[i + 1].first) {
          sum[k] = make_pair(v[i].first, s);
          s = 0;
          k++;
        }
      } else {
        sum[k] = make_pair(v[i].first, s);
      }
    }
    for (int i = 0; i < c; ++i) {
      if (sum[i].second >= 1000000) {
        cout << sum[i].first << endl;
        num++;
      }
    }
    if (num == 0) {
      cout << "NA" << endl;
    }
    cin >> n;
  }
  return 0;
}
