#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) {
    long long a, b, c;
    map<long long, long long> M;
    bool k = false;
    for (long long i = 0; i < (n); i++) {
      cin >> a >> b >> c;
      M[a] += b * c;
    }
    for (auto itr : M) {
      if ((itr.second) >= 1000000) {
        cout << (itr.first) << endl;
        k = true;
      }
    }
    if (k == false) cout << "NA" << endl;
  }
  return 0;
}
