#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int a[4100] = {};
    vector<int> in(n);
    for (int i = (0); i < (int)(n); i++) {
      int p, q, r;
      cin >> p >> q >> r;
      a[p] += q * r;
      in[i] = p;
    }
    bool b = false;
    for (int i = (0); i < (int)(n); i++) {
      if (a[in[i]] >= 1000000) {
        cout << in[i] << endl;
        a[in[i]] = 0;
        b = true;
      }
    }
    if (!b) cout << "NA" << endl;
  }
}
