#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  while (cin >> N && N != 0) {
    cin.get();
    string result, i;
    map<string, long long> sales;
    long long p, q;
    for (int n = 0; n != N; ++n) {
      cin >> i >> p >> q;
      sales[i] += p * q;
    }
    bool printNA = true;
    for (map<string, long long>::iterator it = sales.begin(); it != sales.end();
         ++it) {
      if (it->second >= 1000000) {
        cout << it->first << endl;
        printNA = false;
      }
    }
    if (printNA) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
