#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, X, Y, Z;
  while (true) {
    cin >> N;
    if (N == 0) {
      break;
    }
    vector<long long> P(4001, 0);
    for (int i = 0; i < N; i++) {
      cin >> X >> Y >> Z;
      P[X] += Y * Z;
    }
    int count_ = 0;
    for (int i = 1; i <= 4000; i++) {
      if (P[i] >= 1000000) {
        cout << i << endl;
        count_++;
      }
    }
    if (!count_) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
