#include <bits/stdc++.h>
using namespace std;
template <typename T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <typename T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
long long cost[4010];
signed main(void) {
  while (true) {
    int n;
    cin >> n;
    if (!n) break;
    vector<int> v;
    for (long long i = (long long)0; i < (long long)n; ++i) {
      long long e, p, q;
      cin >> e >> p >> q;
      if (cost[e] < 1000000 && cost[e] + p * q >= 1000000) {
        v.push_back(e);
        cost[e] = 1000000;
      } else {
        cost[e] += p * q;
      }
    }
    if (v.size() == 0) cout << "NA" << endl;
    for (long long i = (long long)0; i < (long long)v.size(); ++i)
      cout << v[i] << endl;
  }
  return 0;
}
