#include <bits/stdc++.h>
using namespace std;
int n;
long long need = (int)1e6;
int main() {
  while (1) {
    cin >> n;
    if (n == 0) break;
    map<long long, long long> sum;
    set<long long> ids;
    for (int i = 0; i < n; i++) {
      long long id, p, q;
      cin >> id >> p >> q;
      ids.insert(id);
      sum[id] += (p * q);
    }
    bool na = true;
    set<long long>::iterator it;
    for (it = ids.begin(); it != ids.end(); it++) {
      if (sum[(*it)] >= need) {
        cout << (*it) << endl;
        na = false;
      }
    }
    if (na) cout << "NA" << endl;
  }
  return 0;
}
