#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;
    }
    int* officer_num_old = new int[dataset_num];
    for (int i = 0; i < dataset_num; i++) {
      int officer_num;
      int price;
      int figure;
      int flag = 0;
      officer_num_old[i] = officer_num;
      std::cin >> officer_num;
      std::cin >> price;
      std::cin >> figure;
      for (int j = 0; j < i; j++) {
        if (officer_num_old[j] == officer_num) {
          flag = 1;
        }
      }
      if (price * figure >= 1000000 && flag == 0) {
        std::cout << officer_num << std::endl;
        count += 1;
      }
    }
    if (count == 0) {
      std::cout << "NA" << std::endl;
    }
  }
  return 0;
}
