#include <bits/stdc++.h>
void initialize(unsigned long long array[][4], int n);
void calculation(unsigned long long array[][4], int n);
void judge_and_output(unsigned long long array[][4], int n);
int main() {
  int i = 0, n = 0;
  while (scanf("%d", &n), (n != 0)) {
    unsigned long long menber[n][4];
    initialize(menber, n);
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &menber[i][0], &menber[i][1], &menber[i][2]);
    }
    calculation(menber, n);
    judge_and_output(menber, n);
  }
  return 0;
}
void initialize(unsigned long long array[][4], int n) {
  int i = 0, j = 0;
  for (; i < n; i++) {
    for (; j < 4; j++) {
      array[i][j] = 0;
    }
  }
}
void calculation(unsigned long long array[][4], int n) {
  int i = 0, j = 0;
  for (; i < n; i++) {
    array[i][3] = array[i][1] * array[i][2];
  }
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (array[i][0] == array[j][0]) {
        array[i][3] += array[j][3];
      }
    }
  }
}
void judge_and_output(unsigned long long array[][4], int n) {
  int i = 0, flag = 0;
  for (; i < n; i++) {
    if ((array[i][3] >= 1000000) && (array[i][3] > 0)) {
      printf("%d\n", array[i][0]);
      flag = 1;
    }
  }
  if (flag == 1) {
    return;
  } else {
    puts("NA");
    return;
  }
}
