#include <bits/stdc++.h>
std::vector<int> staff;
bool search(int number);
int main() {
  int n;
  while (1) {
    int number, price, amount;
    staff.clear();
    std::cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      std::cin >> number >> price >> amount;
      if (price * amount >= 1000000) {
        if (search(number) == false) {
          staff.push_back(number);
        }
      }
    }
    if (staff.empty()) {
      std::cout << "NA" << std::endl;
    } else {
      for (std::vector<int>::iterator p = staff.begin(); p != staff.end();
           p++) {
        std::cout << *p << std::endl;
      }
    }
  }
  return 0;
}
bool search(int number) {
  for (std::vector<int>::iterator p = staff.begin(); p != staff.end(); p++) {
    if (*p == number) return true;
  }
  return false;
}
