#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(const std::vector<T>& v, char sep = ' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << "\n";
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n) {
    int p, q;
    long long int e[1010] = {0}, res[4010] = {0};
    bool judge = false;
    for (int i = (0); i < (int)(n); ++i) {
      cin >> e[i] >> p >> q;
      res[e[i]] += p * q;
    }
    sort(e, e + n);
    for (int i = (0); i < (int)(n); ++i) {
      if (res[e[i]] >= 1000000 && e[i] != e[i + 1]) {
        cout << e[i] << "\n";
        judge = true;
      }
    }
    if (!judge)
      cout << "NA"
           << "\n";
  }
}
