#include <iostream>
#include <map>
#include <algorithm>

const long long BORDER = 1000000;

using namespace std;

int main() {
  bool f;
  int i, j, n, number;
  long long price, amount;
  while(cin >> n) {
    if (n == 0) break;
    
    map<int, long long> m;
    map<int, long long>::iterator it;

    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));
    }
    for (it = m.begin(), f = false; it != m.end(); it++) {
      if (it->second >= BORDER) {
        f = true;
        cout << it->first << endl;
      }
    }
    if (!f) cout << "NA" << endl;
  }

  return 0;
}