#include <bits/stdc++.h>
using namespace std;
long long int solve(long long int N);
int main(void) {
  long long int N = 1;
  while (true) {
    cin >> N;
    if (N == 0) {
      break;
    }
    solve(N);
  }
  return 0;
}
long long int solve(long long int N) {
  map<int, long long int> m;
  set<int> s;
  for (int i = 0; i < N; i++) {
    int id;
    long long int ps, q;
    cin >> id >> ps >> q;
    if (m.find(id) == m.end()) {
      m[id] = ps * q;
    } else {
      m[id] += ps * q;
    }
    if (m[id] >= 1000000) s.insert(id);
  }
  if (s.size() == 0) {
    cout << "NA" << endl;
  } else {
    for (auto it = s.begin(); it != s.end(); ++it) {
      cout << (*it) << endl;
    }
  }
  return 0;
}
