#include <bits/stdc++.h>
int main() {
  int n;
  while (scanf("%d", &n), n) {
    int i, num, flag = 0;
    long unitPrice, saleQuantity, earning[4000] = {0};
    for (i = 0; i < n; i++) {
      scanf("%d%ld%ld", &num, &unitPrice, &saleQuantity);
      earning[num - 1] += unitPrice * saleQuantity;
    }
    for (i = 0; i < 4000; i++) {
      if (earning[i] >= 1000000) {
        printf("%d\n", i + 1);
        flag += 1;
      }
    }
    if (flag == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
