#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    int cnt = 0;
    cin >> cnt;
    if (cnt == 0) break;
    std::vector<std::pair<long, long> > data;
    for (int i = 0; i < cnt; ++i) {
      int id, price, amount;
      cin >> id >> price >> amount;
      int g = price * amount;
      bool found = false;
      for (int i = 0; i < data.size(); ++i) {
        if (data[i].first == id) {
          data[i].second += g;
          found = true;
        }
      }
      if (!found) data.push_back(std::pair<int, int>(id, g));
    }
    bool bHitted = false;
    for (std::vector<std::pair<long, long> >::iterator it = data.begin();
         it != data.end(); ++it) {
      if (it->second >= 1000000) {
        cout << it->first << "\n";
        bHitted = true;
      }
    }
    if (!bHitted) {
      cout << "NA\n";
    }
  }
  return 0;
}
