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