#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> emp_nums;
  vector<int> grades;
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    int e, p, q;
    for (int i = 0; i < n; i++) {
      cin >> e >> p >> q;
      bool be_already = false;
      int same_emp_index;
      for (int j = 0; j < emp_nums.size(); j++) {
        if (emp_nums[j] == e) {
          be_already = true;
          same_emp_index = j;
          break;
        }
      }
      if (be_already) {
        grades[same_emp_index] += p * q;
      } else {
        emp_nums.push_back(e);
        grades.push_back(p * q);
      }
    }
  }
  for (int i = 0; i < emp_nums.size(); i++) {
    if (grades[i] >= 1000000)
      cout << emp_nums[i] << endl;
    else
      cout << "NA" << endl;
  }
}
