#include <bits/stdc++.h>
int main() {
  int n, id, p, q;
  std::map<int, int> workers;
  std::map<int, int>::iterator it;
  while (std::cin >> n) {
    if (!n) break;
    for (int i = 0; i < n; i++) {
      std::cin >> id >> p >> q;
      workers[id] += p * q;
    }
    bool found = false;
    for (it = workers.begin(); it != workers.end(); it++) {
      if (it->second >= 1000000) {
        std::cout << it->first << std::endl;
        found = true;
      }
    }
    if (!found) std::cout << "NA" << std::endl;
    workers.clear();
  }
  return 0;
}
