#include <bits/stdc++.h>
typedef struct {
  int num;
  int tan;
  int suu;
  int to;
} SYAIN;
typedef struct {
  int check;
  int too;
} CHEE;
int main() {
  SYAIN syai[4000];
  CHEE check[4000];
  int a, b = 4000;
  int c = 0;
  while (1) {
    for (a = 0; a < b; a++) {
      syai[a].num = 0;
      syai[a].to = 0;
      syai[a].tan = 0;
      syai[a].suu = 0;
      check[a].check = 0;
      check[a].too = 0;
    }
    scanf("%d", &b);
    if (b == 0) break;
    for (a = 0; a < b; a++) {
      scanf("%d %d %d", &syai[a].num, &syai[a].tan, &syai[a].suu);
      if (check[syai[a].num].check == 1) {
        syai[check[syai[a].num].too].to =
            syai[check[syai[a].num].too].to + syai[a].tan * syai[a].suu;
      } else {
        check[syai[a].num].check = 1;
        syai[a].to = syai[a].tan * syai[a].suu;
        check[syai[a].num].too = a;
      }
    }
    for (a = 0; a < b; a++) {
      if (syai[a].to >= 1000000) {
        printf("%d\n", syai[a].num);
        c = c + 1;
      }
    }
    if (c == 0) {
      printf("NA\n");
    }
    c = 0;
  }
  return 0;
}
