#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    int a[4010] = {}, b[4010] = {};
    memset(a, -1, sizeof(a));
    for (int i = 0; i < n; i++) {
      int e, p, q;
      cin >> e >> p >> q;
      b[e] += p * q;
      if (a[e] < 0) a[e] = i;
    }
    vector<int> ans;
    for (int i = 1; i <= 4000; i++) {
      if (b[i] >= 1000000) ans.emplace_back(i);
    }
    sort(ans.begin(), ans.end(), [&](int p, int q) {
      return a[p] < a[q];
    });
    if (ans.empty()) {
      cout << "NA" << endl;
    } else {
      for (auto i : ans) cout << i << endl;
    }
  }

  return 0;
}
