#include <bits/stdc++.h>
using namespace std;
long long int p, q, x[100002];
map<long long int, long long int> sells, vis;
vector<long long int> v;
int main() {
  long long int a, b, c, d, i, j, y, z;
  while (scanf("%lld", &a) != EOF) {
    v.clear();
    sells.clear();
    vis.clear();
    if (a == 0) break;
    for (i = 1; i <= a; i++) {
      scanf("%lld %lld %lld", &z, &p, &q);
      sells[z] += p * q;
      if (sells[z] >= 1000000 && vis[z] != 1) {
        vis[z] = 1;
        v.push_back(z);
      }
    }
    if (v.size() == 0) {
      printf("NA\n");
      continue;
    }
    for (i = 0; i < v.size(); i++) {
      printf("%lld\n", v[i]);
    }
  }
  return 0;
}
