#include <bits/stdc++.h>
int main(void) {
  int i, j, k, l, N, num, point, data, sum;
  long long int mon[4000], dec[4000];
  while (1) {
    scanf("%d", &N);
    j = 0;
    if (N == 0) {
      break;
    }
    for (i = 0; i < N; i++) {
      scanf("%d %d %d", &num, &point, &data);
      sum = data * point;
      mon[i] = sum;
      dec[i] = num;
      j++;
      for (k = 0; k < i; k++) {
        if (dec[k] == num) {
          mon[k] = mon[k] + sum;
          mon[i] = dec[i] = 0;
        }
      }
    }
    l = 0;
    for (k = 0; k < j; k++) {
      if (mon[k] >= 1000000) {
        printf("%lld\n", dec[k]);
        l++;
      }
    }
    if (l == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
