#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long long int LINF = (long long int)4000000000000000000;
const long long int MOD = (long long int)1000000007;
const double PI = acos(1.0);
const int limit = 100010;
int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0) break;
    bool na = true;
    set<long long int> st;
    map<long long int, long long int> mp;
    for (long long int k = 0; k < (long long int)(n); k++) {
      long long int i, p, q;
      cin >> i >> p >> q;
      st.insert(i);
      mp[i] += p * q;
    }
    auto itr = st.begin();
    for (int i = 0; i < st.size(); i++, itr++) {
      if (mp[*itr] >= 1000000) {
        cout << *itr << endl;
        na = false;
      }
    }
    if (na) cout << "NA" << endl;
  }
  return 0;
}
