#include <iostream>
#include <vector>

using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    vector<pair<int, long long>> seq;
    long long int id, p, q;
    for (int i = 0; i < n; ++i) {
      cin >> id >> p >> q;

      bool flag = true;
      for (auto &v : seq) {
        if (v.first == id) {
          flag = false;
          v.second += p * q;
          break;
        }
      }
      if (flag)
        seq.push_back(make_pair(id, p * q));
    }

    bool flag2 = true;
    for (auto &v : seq) {
      if (v.second >= 1e6) {
        cout << v.first << endl;
        flag2 = false;
      }
    }

    if (flag2)
      cout << "NA" << endl;
  }
}
