#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  while (scanf("%d", &n), n) {
    map<int, long long> m;
    map<int, long long>::iterator it;
    for (int i = 0; i < n; i++) {
      int x;
      long long p, q;
      scanf("%d%lld%lld", &x, &p, &q);
      m[x] += p * q;
    }
    bool ok = true;
    for (it = m.begin(); it != m.end(); it++) {
      long long tmp = it->second;
      if (tmp >= 1000000) {
        ok = false;
        printf("%d\n", it->first);
      }
    }
    if (ok) printf("NA\n");
  }
  return 0;
}
