#include <bits/stdc++.h>
void set_zero(int v[]) {
  int i;
  for (i = 0; i < 4001; i++) {
    v[i] = 0;
  }
}
void set_zero_zero(long long int v[]) {
  int i;
  for (i = 0; i < 4001; i++) {
    v[i] = 0;
  }
}
int main(void) {
  int n;
  int number[4001];
  long long int price[4001];
  long long int kosu[4001];
  int harasyo[4001];
  long long int sum[4001];
  int i, j;
  int flag;
  while (scanf("%d", &n)) {
    set_zero(harasyo);
    set_zero_zero(sum);
    flag = 0;
    if (n == 0) {
      break;
    }
    for (i = 0; i < n; i++) {
      scanf("%d %lld %lld", &number[i], &price[i], &kosu[i]);
      sum[i] = price[i] * kosu[i];
    }
    for (i = 0; i < n; i++) {
      for (j = 1; j < n; j++) {
        if (number[i] == number[i + j]) {
          sum[i] += sum[i + j];
        }
      }
    }
    for (i = 0; i < n; i++) {
      if (sum[i] >= 1000000) {
        harasyo[i] = number[i];
        flag = 1;
      }
    }
    if (flag == 1) {
      for (i = 0; i <= 4000; i++) {
        if (harasyo[i] != 0) {
          printf("%d\n", harasyo[i]);
          flag = 0;
        }
      }
    }
    printf("NA\n");
  }
  return 0;
}
