#include <bits/stdc++.h>
int main(void) {
  long long int a[4000] = {0}, b[4000], c[4000];
  int date, to, i, j, cou[4000] = {0};
  while (1) {
    scanf("%d", &date);
    if (date == 0) break;
    for (i = 0; i < date; i++) {
      scanf("%d %lld %lld", &a[i], &b[i], &c[i]);
      cou[i] = b[i] * c[i];
      for (j = 0; j < i; j++) {
        if (cou[i] == cou[j]) {
          cou[j] = cou[i] + cou[j];
          cou[i] = 0;
        }
      }
    }
    to = 0;
    for (i = 0; i < date; i++) {
      if (cou[i] >= 1000000) {
        printf("%d\n", a[i]);
        to = 1;
      }
    }
    if (to == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
