#include <bits/stdc++.h>
const long long BORDER = 1000000;
using namespace std;
int main() {
  bool f;
  int i, j, n, number;
  vector<map<int, long long> > datas;
  long long price, amount;
  map<int, long long>::iterator it;
  while (cin >> n) {
    if (n == 0) break;
    map<int, long long> m;
    for (i = 0; i < n; i++) {
      cin >> number >> price >> amount;
      it = m.find(number);
      if (it != m.end())
        it->second += price * amount;
      else
        m.insert(pair<int, long long>(number, price * amount));
    }
    datas.push_back(m);
  }
  for (i = 0; i < datas.size(); i++) {
    for (it = datas[i].begin(), f = false; it != datas[i].end(); it++) {
      if (it->second >= BORDER) {
        f = true;
        cout << it->first << endl;
      }
    }
    if (!f) cout << "NA" << endl;
  }
  return 0;
}
