#include <bits/stdc++.h>
using namespace std;
static const int MAX_N = 4000;
int n, e, p, q;
long long int a[MAX_N];
int main() {
  while (1) {
    for (int i = 0; i < MAX_N; i++) {
      a[i] = 0;
    }
    cin >> n;
    if (n == 0) break;
    for (int i = 1; i <= n; i++) {
      cin >> e >> p >> q;
      e--;
      a[e] += p * q;
    }
    bool def = false;
    for (int i = 0; i < MAX_N; i++) {
      if (a[i] >= 1000000LL) {
        cout << i + 1 << endl;
        def = true;
      }
    }
    if (def == false) cout << "NA" << endl;
  }
  return 0;
}
