#include <bits/stdc++.h>
using namespace std;
long double dot(complex<long double> a, complex<long double> b) {
  return real(conj(a) * b);
}
long double cross(complex<long double> a, complex<long double> b) {
  return imag(conj(a) * b);
}
long long score[4001];
int main() {
  while (true) {
    int n;
    cin >> n;
    if (!n) break;
    for (long long i = 0; i < 4001; ++i) score[i] = 0;
    for (long long i = 0; i < n; ++i) {
      int id;
      long long val, num;
      cin >> id >> val >> num;
      score[id] += val * num;
    }
    bool flag = true;
    for (long long i = 0; i < 4001; ++i) {
      if (score[i] >= 1000000) {
        flag = false;
        cout << i << endl;
      }
    }
    if (flag) cout << "NA" << endl;
  }
  return 0;
}
