#include <bits/stdc++.h>
int output[50000];
int count = 0;
void input(int);
int main(void) {
  int n, k;
  do {
    scanf("%d", &n);
    if (n != 0) input(n);
  } while (n > 0);
  for (k = 0; k < count; k++) {
    if (output[k] != 0) {
      printf("%d\n", output[k]);
    } else {
      printf("NA\n");
    }
  }
  return 0;
}
void input(int ns) {
  int e[ns];
  long p[ns];
  long q[ns];
  long c[ns];
  int i;
  for (i = 0; i < ns; i++) {
    scanf("%d %d %d", &e[i], &p[i], &q[i]);
    c[i] = p[i] * q[i];
  }
  int j;
  for (i = 0; i < ns - 1; i++) {
    for (j = 1; j < ns; j++) {
      if (e[i] == e[j]) {
        c[i] = c[i] + c[j];
        c[j] = 0;
      }
    }
  }
  int ch = 0;
  for (i = 0; i < ns - 1; i++) {
    if (c[i] >= 1000000) {
      output[count] = e[i];
      count++;
      ch = 1;
    }
  }
  if (ch == 0) {
    output[count] = 0;
    count++;
  }
}
