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