#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1000000009;
signed main() {
  long long n;
  while (cin >> n, n) {
    map<long long, long long> M;
    for (long long i = 0; i < n; i++) {
      long long e, p, q;
      cin >> e >> p >> q;
      M[e] += p * q;
    }
    bool f = false;
    for (auto itr = M.begin(); itr != M.end(); itr++) {
      if ((itr->second) >= 1000000) {
        cout << (itr->first) << endl;
        f = true;
      }
    }
    if (!f) cout << "NA" << endl;
  }
  return 0;
}
