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