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