#include <bits/stdc++.h>
int main(int, char**) {
  int n;
  while (std::cin >> n) {
    if (!n) break;
    bool ex(0);
    std::map<short, long long> tbl;
    while (n--) {
      int Cnum, at, num;
      std::cin >> Cnum >> at >> num;
      tbl[Cnum] += at * num;
    }
    for (std::map<short, long long>::const_iterator it = tbl.begin();
         it != tbl.end(); ++it) {
      if ((it->second) >= 1000000) {
        std::cout << it->first << std::endl;
        ex = 1;
      }
    }
    if (!ex) std::cout << "NA" << std::endl;
  }
  return 0;
}
