#include <bits/stdc++.h>
int main(void) {
  int n, i, number, price, howmany;
  long long int score[4001];
  scanf("%d", n);
  while (n != 0) {
    for (i = 0; i <= 4000; i++) {
      score[i] = 0;
    }
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", number, price, howmany);
      score[number] += price * howmany;
    }
    for (i = 1; i <= 4000; i++) {
      if (score[i] >= 1000000) {
        printf("%lld\n", i + 1);
        score[0]++;
      }
    }
    if (score[0] == 0) {
      printf("NA\n", i + 1);
    }
    scanf("%d", n);
  }
}
