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