#include <bits/stdc++.h>
int main() {
  int n, i, count, bango, tanka, kosuu;
  long long int uriage[4000];
  scanf("%d", &n);
  while (n != 0) {
    for (i = 0; i < 4000; i++) {
      uriage[i] = 0;
    }
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &bango, &tanka, &kosuu);
      uriage[bango] += (tanka * kosuu);
    }
    count = 0;
    for (i = 0; i < 4000; i++) {
      if (uriage[i] >= 1000000) {
        printf("%d\n", i);
        count++;
      }
    }
    if (count == 0) {
      printf("NA\n");
    }
    scanf("%d", &n);
  }
  return 0;
}
