#include <bits/stdc++.h>
typedef struct {
  int id;
  long long total;
} sales_t;
int main(void) {
  sales_t sales[4000], *s, *employee[4000];
  int eid, p, q, n, i, sales_idx, pcnt;
  while (scanf("%d", &n) != EOF && n) {
    sales_idx = 0;
    for (i = 0; i < 4000; i++) {
      employee[i] = NULL;
    }
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &eid, &p, &q);
      if (employee[eid] == NULL) {
        s = &sales[sales_idx++];
        s->id = eid;
        s->total = p * q;
        employee[eid] = s;
      } else {
        employee[eid]->total += p * q;
      }
    }
    for (i = 0, pcnt = 0; i < sales_idx; i++) {
      if (sales[i].total >= 1000000) {
        printf("%d\n", sales[i].id);
        pcnt++;
      }
    }
    if (!pcnt) {
      puts("NA");
    }
  }
  return 0;
}
