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