#include <bits/stdc++.h>
using namespace std;
long long worker[4001];
int main() {
  int n, id;
  long long p, q;
  while (cin >> n && n) {
    fill((long long*)worker, (long long*)(worker + 4001), 0);
    for (int i = 0; i < n; ++i) {
      cin >> id >> p >> q;
      worker[id] += p * q;
    }
    bool isNA = 1;
    for (int i = 1; i < 4001; ++i) {
      if (worker[i] >= 1000000) {
        cout << i << endl;
        isNA = 0;
      }
    }
    if (isNA) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
