#include <bits/stdc++.h>
int main(void) {
  int i, j, count;
  int data, number[4000], tanka[4000], kosu[4000];
  long long int uriage[4000];
  while (1) {
    for (i = 0; i < 4000; i++) uriage[i] = 0;
    count = 0;
    scanf("%d", &data);
    if (data != 0) {
      for (i = 0; i < data; i++) {
        scanf("%d %d %d", &number[i], &tanka[i], &kosu[i]);
        uriage[i] += (tanka[i] * kosu[i]);
        for (j = 0; j < i; j++) {
          if (number[i] == number[j]) {
            uriage[j] += uriage[i];
            uriage[i] = 0;
          }
        }
      }
      for (i = 0; i < data; i++) {
        if (uriage[i] >= 1000000) {
          printf("%d\n", number[i]);
          count++;
        }
      }
      if (count == 0) printf("NA\n");
    }
    if (data == 0) break;
  }
  return 0;
}
