#include <bits/stdc++.h>
int main() {
  int sum[4000];
  int i, p, q, n;
  int j;
  int flag = 0;
  while (1) {
    for (j = 0; j < 4000; j++) {
      sum[j] = 0;
    }
    scanf("%d", &n);
    if (n == 0) break;
    for (j = 0; j < n; j++) {
      scanf("%d", &i);
      scanf("%d", &p);
      scanf("%d", &q);
      sum[i] += p * q;
    }
    for (j = 0; j < 4000; j++) {
      if (sum[j] >= 1000000) {
        printf("%d\n", j);
        flag = 1;
      }
    }
    if (flag == 0) {
      printf("NA\n");
    }
    flag = 0;
  }
  return 0;
}
