#include <bits/stdc++.h>
using namespace std;
void solveAndOutput(map<int, long long> data, vector<int> bangouList) {
  int outputCount = 0;
  for (int i = (0); i < (bangouList.size()); ++i) {
    if (data[bangouList[i]] >= 1000000) {
      cout << bangouList[i] << endl;
      outputCount++;
    }
  }
  if (outputCount == 0) cout << "NA" << endl;
}
int main() {
  int n;
  map<int, long long> data;
  vector<int> bangouList;
  cin.tie(0);
  ios::sync_with_stdio(false);
  ;
  while (cin >> n, n) {
    data.clear();
    bangouList.clear();
    while (n--) {
      int bangou = 0, tanka = 0, suu = 0;
      cin >> bangou >> tanka >> suu;
      if (data[bangou] == 0) bangouList.push_back(bangou);
      data[bangou] += tanka * suu;
    }
    solveAndOutput(data, bangouList);
  }
  return 0;
}
