#include <bits/stdc++.h>
int main(void) {
  int N[4000];
  long long int P[4000], A[4000], M[4000];
  int a, b, c, d;
  for (b = 0;; b = 0) {
    scanf("%d", &c);
    for (a = 0; a < c; a++) {
      scanf("%d %lld %lld", &N[a], &P[a], &A[a]);
      M[a] = P[a] * A[a];
      for (d = 0; d < a; d++)
        if (N[a] == N[d]) {
          M[a] += M[d];
          M[d] = 0;
        }
    }
    for (a = 0; a < c; a++)
      if (M[a] >= 1000000) {
        printf("%d\n", N[a]);
        b++;
      }
    if (b == 0) printf("NA\n");
  }
  return 0;
}
