#include <bits/stdc++.h>
int main() {
  int n;
  std::map<int, long long> m;
  while (std::cin >> n, n) {
    m.clear();
    for (long long a, b, c, i = 0; i < n; ++i) {
      std::cin >> a >> b >> c;
      m[a] += b * c;
    }
    bool f = false;
    for (auto it = m.begin(); it != m.end(); ++it)
      if (it->second >= 1000000) std::cout << it->first << std::endl, f = true;
    if (!f) std::cout << "NA" << std::endl;
  }
  return 0;
}
