#include <bits/stdc++.h>
int SearchNumber(int a[], int num, int member) {
  int i = 0;
  for (i = 0; i < member; i++) {
    if (a[i] == num) return i;
  }
  return -1;
}
int main(void) {
  int *num_list, num, val, kazu;
  long long *sum;
  int member;
  int n;
  int flag;
  int i, j;
  int work;
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    member = 0;
    flag = 0;
    num_list = (int *)malloc(sizeof(int) * n);
    sum = (long long *)malloc(sizeof(long long) * n);
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &num, &val, &kazu);
      work = SearchNumber(num_list, num, member);
      if (work == -1) {
        num_list[member] = num;
        sum[member] = val * kazu;
        member++;
      } else {
        if (sum[work] < 1000000) sum[work] += val * kazu;
      }
    }
    for (i = 0; i < member; i++) {
      if (sum[i] >= 1000000) {
        printf("%d\n", num_list[i]);
        flag = 1;
      }
    }
    if (flag == 0) puts("NA");
    free(num_list);
    free(sum);
  }
  return 0;
}
