#include <bits/stdc++.h>
int main() {
  int n;
  while (1) {
    std::cin >> n;
    if (n == 0) break;
    bool f = false;
    std::vector<int> vec;
    for (int i = 0; i < n; i++) {
      int a, b, c;
      std::cin >> a >> b >> c;
      if (b * c >= 1000000) vec.push_back(a);
    }
    if (vec.empty())
      std::cout << "NA" << std::endl;
    else {
      for (int i = 0; i < vec.size(); i++) {
        std::cout << vec[i] << std::endl;
      }
    }
  }
  return 0;
}
