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