#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<long long, long long>;
const long long MOD = 1e9 + 7;
signed main() {
  long long E[4010] = {};
  for (long long n; cin >> n && n;) {
    memset(E, 0, sizeof(E));
    for (long long i = (0); i < (n); i++) {
      long long e, p, q;
      cin >> e >> p >> q;
      E[e] += p * q;
    }
    bool flag = true;
    for (long long i = (0); i < (4010); i++) {
      if (E[i] >= 1000000) {
        flag = false;
        cout << i << endl;
      }
    }
    if (flag) cout << "NA" << endl;
  }
  return 0;
}
