#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    int count = 0;
    unordered_map<int, int> dic;
    int ids[n];
    for (int i = 0; i < n; i++) {
      int id, p, c;
      cin >> id >> p >> c;
      ids[i] = id;
      if (dic.find(id) == dic.end()) dic[id] = 0;
      dic[id] += p * c;
    }
    vector<int> printed;
    for (int i = 0; i < n; i++) {
      bool print = false;
      for (int j = 0; j < printed.size(); j++) {
        if (printed[j] == ids[i]) {
          print = true;
          break;
        }
      }
      if (print) continue;
      if (dic[ids[i]] >= 1000000) {
        cout << ids[i] << endl;
        printed.push_back(ids[i]);
        count++;
      }
    }
    if (count == 0 && n > 0) cout << "NA" << endl;
  }
  return 0;
}
