#include <bits/stdc++.h>
int main() {
  long long int A[4001] = {0}, a, b;
  int i, d, n = 1;
  int cnt = 0;
  while (n != 0) {
    scanf("%d", &n);
    if (n == 0) break;
    cnt = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %lld %lld", &d, &a, &b);
      A[d] += a * b;
    }
    for (i = 1; i < 4001; i++) {
      if (A[i] >= 1000000) {
        printf("%d\n", i);
        cnt++;
        A[i] = 0;
      }
    }
    if (cnt == 0) printf("NA\n");
  }
  return 0;
}
