#include <bits/stdc++.h>
int main(void) {
  struct ID {
    unsigned int id;
    unsigned int unit;
    unsigned int number;
  };
  unsigned int n, k, i, p, q, pro, count;
  struct ID *member;
  while (scanf("%d", &n) && n != 0) {
    member = (struct ID *)calloc(n, sizeof(struct ID));
    for (k = 0; k < n; k++) {
      scanf("%u %u %u", &((member + k)->id), &((member + k)->unit),
            &((member + k)->number));
    }
    count = 0;
    for (k = 0; k < n; k++) {
      pro = ((member + k)->unit) * ((member + k)->number);
      if (pro >= 1000000) {
        printf("%d\n", (member + k)->id);
        count += 1;
      }
    }
    if (count == 0) printf("NA\n");
    free(member);
  }
  return 0;
}
