#include <bits/stdc++.h>
struct x {
  int name;
  int kachi;
  int kosu;
};
int main(void) {
  int n;
  int b[4000] = {0};
  int i, j, k;
  int count = 0;
  long long int a = 0;
  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;
    struct x xx[n];
    for (i = 0; i < n; i++) {
      scanf("%d", &xx[i].name);
      scanf("%d", &xx[i].kachi);
      scanf("%d", &xx[i].kosu);
      for (k = 0; k < i; k++) {
        if (xx[k].name == xx[i].name) {
          xx[k].kachi += xx[i].kachi;
          xx[k].kosu += xx[i].kosu;
          xx[i].kachi = 1;
          xx[i].kosu = 1;
        }
      }
      a = xx[i].kachi * xx[i].kosu;
      if (a >= 1000000) b[i] = 1;
    }
    for (j = 0; j < n; j++) {
      if (b[j] == 1)
        printf("%d\n", xx[j].name);
      else
        count++;
      b[j] = 0;
    }
    if (count == n) printf("NA\n");
    count = 0;
  }
  return 0;
}
