#include<stdio.h>
main(void){
  long long int a[4000],b[4000],c[4000],smp[4000]={0};
  int n,i,j,k,x;
  while(1){
    scanf("%d",&n);
    if(n == 0)break;
    for(i=0;i<n;i++){
      scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
    }
    x = 0;
    for(j=0;j<n;j++){
      for(k=j+1;k<n;k++){
	smp[j] = b[j]*c[j];
	if(a[j] == a[k]){
	  smp[j] = smp[j]+smp[k];
	}
      }
      if(smp[j] >= 1000000){
	printf("%d\n",a[j]);
	x++;
      }
    }
    if(x == 0){
      printf("NA\n");
    }
  }
  return 0;
}