#include <bits/stdc++.h>
using Sale = std::pair<int, int>;
int main() {
  int n;
  while (1) {
    std::cin >> n;
    if (n == 0) break;
    std::vector<Sale> data(n);
    for (auto &d : data) {
      int price, num;
      std::cin >> d.first >> price >> num;
      d.second = price * num;
    }
    std::vector<Sale> unduplicate_data;
    for (auto &d : data) {
      auto s = std::find_if(
          unduplicate_data.begin(), unduplicate_data.end(),
          [d](const Sale &s) -> bool { return s.first == d.first; });
      if (s == unduplicate_data.end()) {
        unduplicate_data.push_back(d);
      } else {
        s->second += d.second;
      }
    }
    bool isNA = true;
    for (auto d : unduplicate_data) {
      if (d.second >= 1000000) {
        std::cout << d.first << std::endl;
        isNA = false;
      }
    }
    if (isNA) std::cout << "NA" << std::endl;
  }
}
