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