#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& os, pair<S, T> p) {
  os << '(' << (p.first) << ", " << (p.second) << ')';
  return os;
}
template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i = 1, len = v.size(); i < len; ++i) os << ' ' << v[i];
  return os;
}
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
int main() {
  int n;
  while (cin >> n, n) {
    int xs[4002];
    calloc(sizeof(xs), sizeof(int));
    vector<int> order;
    for (int i = int(0); i != int((0) + (1) * ((n))); i += (1)) {
      int a, b, c;
      cin >> a >> b >> c;
      xs[a] = min(1000000, xs[a] + b * c);
      order.push_back(a);
    }
    bool bl = true;
    for (int id : order) {
      if (xs[id] >= 1000000) {
        cout << id << endl;
        bl = false;
        xs[id] = 0;
      }
    }
    if (bl) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
