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