#include <bits/stdc++.h>
int main() {
  int i, x, y, z, n;
  int sum[4001], count;
  while (1) {
    count = 0;
    for (i = 1; i <= 4000; i++) sum[i] = 0;
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &x, &y, &z);
      sum[x] += y * z;
    }
    for (i = 1; i <= 4000; i++) {
      if (sum[i] >= 1000000) {
        printf("%d\n", i);
        count = 1;
      }
    }
    if (count == 0) printf("NA\n");
  }
  return 0;
}
