#include <bits/stdc++.h>
int main() {
  long long int total[4000], n, a, b, c;
  while (1) {
    scanf("%lld", &n);
    if (n == 0) break;
    memset(total, 0, sizeof(total));
    while (n--) {
      scanf("%lld%lld%lld", &a, &b, &c);
      total[a - 1] = total[a - 1] + b * c;
    }
    int res = 0;
    for (int i = 0; i < 4000; i++) {
      if (total[i] >= 1000000) {
        res = 1;
        printf("%d\n", i + 1);
      }
    }
    if (res)
      continue;
    else
      printf("NA\n");
  }
  return 0;
}
