#include<stdio.h>

int main(void){
  int n;
  int i,j;
  int id[4000];
  long long int value[4000],num[4000],sale[4000];
  int c;

  while(1){
    scanf("%d",&n);
    if(!n)break;

    for(i=0;i<n;i++){
      scanf("%d %lld %lld",&id[i],&value[i],&num[i]);
      sale[i] = value[i] * num[i];
      for(j=0;j<i;j++)if(id[j] == id[i])break;
      if(j!=i){
	sale[j] += sale[i];
	i--;
	n--;
      }
    }

    c = 0;
    for(i=0;i<n;i++){
      if(1000000.0 - sale[i] < 1e-10){
	printf("%d\n",id[i]);
	c++;
      }
    }	 
    if(!c)printf("NA\n");

  }
 return 0;