#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long a;
  while (scanf("%lld", &a), a) {
    unordered_map<long long, long long> c;
    for (long long d = 0; d < a; d++) {
      long long e, f, k;
      scanf("%lld%lld%lld", &e, &f, &k);
      c[e] += f * k;
    }
    bool s = true;
    for (auto g = c.begin(); g != c.end(); g++) {
      if (g->second >= 1000000) {
        s = false;
        printf("%lld\n", g->first);
      }
    }
    if (s) printf("NA\n");
  }
}
