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