#include <bits/stdc++.h>
int main() {
  int i, j, n, no, flag, tmp;
  int data[4001], total[4001];
  long long int price, num;
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    memset(data, 0, sizeof(data));
    memset(total, 0, sizeof(total));
    tmp = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %lld %lld", &no, &price, &num);
      data[i] = no;
      total[i] = price * num;
      for (j = 0; j < i; j++) {
        if (data[j] == data[i]) {
          total[j] += total[i];
          data[i] = 0;
          total[i] = 0;
        }
      }
    }
    for (i = 0; i < n; i++) {
      if (total[i] >= 1000000) {
        printf("%d\n", data[i]);
        tmp = 1;
      }
    }
    if (tmp == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
