#include <bits/stdc++.h>
int main(void) {
  int i, num, j, k;
  int set;
  int staffSales[4000];
  int staff[4000], price, sales;
  int passtaff[1000][4000];
  int button;
  int maxsn;
  int kmem[4000];
  for (i = 0;; i++) {
    maxsn = 0;
    scanf("%d", &set);
    if (set == 0) {
      break;
    }
    for (j = 0; j < 4000; j++) {
      staffSales[j] = 0;
    }
    for (j = 0; j < set; j++) {
      scanf("%d%d%d", &staff[j], &price, &sales);
      if (maxsn < staff[j]) {
        maxsn = staff[j];
      }
      staffSales[staff[j] - 1] += price * sales;
    }
    k = 0;
    for (j = 0; j < maxsn; j++) {
      if (staffSales[j] >= 1000000) {
        passtaff[i][k] = j + 1;
        k++;
      }
    }
    kmem[i] = k;
  }
  num = i;
  for (i = 0; i < num; i++) {
    button = 0;
    for (j = 0; j < kmem[i]; j++) {
      button = 1;
      printf("%d\n", passtaff[i][j]);
    }
    if (button == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
