#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  int data_set = 0;
  bool do_continue = true;
  std::vector<string> result;
  while (do_continue) {
    cin >> num;
    if ((num == 0) || (data_set > 50)) {
      do_continue = false;
    } else {
      bool na_flg = true;
      data_set++;
      std::map<int, int> e;
      std::vector<int> employee;
      int fst, snd, thd;
      for (int i = 0; i < num; i++) {
        cin >> fst >> snd >> thd;
        employee.push_back(fst);
        if (e.count(employee[i])) {
          e[employee[i]] += snd * thd;
        } else {
          e[employee[i]] = snd * thd;
        }
      }
      for (unsigned int j = 0; j < employee.size(); j++) {
        if (e[employee[j]] >= 1000000) {
          na_flg = false;
          result.push_back(std::to_string(employee[j]));
        }
      }
      if (na_flg) {
        result.push_back("NA");
      }
    }
  }
  for (unsigned int i = 0; i < result.size() - 1; i++) {
    cout << result[i] << endl;
  }
  return 0;
}
