#include <bits/stdc++.h>
int main() {
  bool loop = true;
  while (loop) {
    int dataset_num;
    int count = 0;
    std::cin >> dataset_num;
    if (dataset_num == 0) {
      loop = false;
      break;
    }
    for (int i = 0; i < dataset_num; i++) {
      int officer_num;
      int price;
      int figure;
      int officer_num_old;
      officer_num_old = officer_num;
      std::cin >> officer_num;
      std::cin >> price;
      std::cin >> figure;
      if (price * figure >= 1000000 && officer_num != officer_num_old) {
        std::cout << officer_num << std::endl;
        count += 1;
      }
    }
    if (count == 0) {
      std::cout << "NA" << std::endl;
    }
  }
  return 0;
}
