#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, id, p, q;
  while (cin >> n && n) {
    map<long long, long long> output;
    for (int i = 0; i < n; ++i) {
      cin >> id >> p >> q;
      output[id] += p * q;
    }
    bool na = true;
    for (auto x : output) {
      if (1000000 <= x.second) {
        cout << x.first << endl;
        na = false;
      }
    }
    if (na) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
