#include <bits/stdc++.h>
using namespace std;
bool find(vector<int> idx, int no);
int main() {
  while (true) {
    int data_num;
    cin >> data_num;
    if (data_num == 0) {
      break;
    }
    vector<int> idx;
    map<int, long> sale;
    while (data_num--) {
      int no, price, num;
      cin >> no >> price >> num;
      long sum = price * num;
      if (find(idx, no)) {
        sale.at(no) += sum;
      } else {
        idx.push_back(no);
        sale.insert(make_pair(no, sum));
      }
    }
    bool is_exist = false;
    for (size_t i = 0; i < idx.size(); i++) {
      if (sale.at(idx.at(i)) >= 1000000) {
        cout << idx.at(i) << endl;
        is_exist = true;
      }
    }
    if (!is_exist) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
bool find(vector<int> idx, int no) {
  for (size_t i = 0; i < idx.size(); i++) {
    if (no == idx.at(i)) {
      return true;
    }
  }
  return false;
}
