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