#include <bits/stdc++.h>
using namespace std;
int main() {
  int id, cost, amount, n;
  while (cin >> n, n) {
    map<int, long long> emps;
    vector<int> ids;
    bool exist = false;
    for (int i = 0; i < n; i++) {
      cin >> id >> cost >> amount;
      if (emps.find(id) != emps.end()) {
        emps[id] += cost * amount;
      } else {
        emps[id] = cost * amount;
        ids.push_back(id);
      }
    }
    for (int i = 0; i < ids.size(); i++) {
      if (emps.at(ids[i]) >= 1000000) {
        cout << ids[i] << endl;
        exist = true;
      }
    }
    if (!exist) cout << "NA" << endl;
  }
  return 0;
}
