#include <bits/stdc++.h>
typedef struct {
  int bango;
  int tanka;
  int kazu;
  int total;
} sub;
int main() {
  sub sub[4444];
  int n;
  int i, j, k;
  int count = 0;
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &sub[i].bango, &sub[i].tanka, &sub[i].kazu);
      sub[i].total = sub[i].tanka * sub[i].kazu;
    }
    for (i = 0; i < n; i++) {
      for (j = i + 1; j < n; j++) {
        if (sub[i].bango == sub[j].bango) {
          sub[i].total += sub[j].total;
          sub[j].total = 0;
        }
      }
    }
    for (i = 0; i < n; i++) {
      if (sub[i].total >= 1000000) {
        printf("%d\n", sub[i].bango);
        count++;
      }
    }
    if (count == 0) {
      printf("NA\n");
    }
    count = 0;
  }
  return 0;
}
