#include <stdio.h>
#include <stdlib.h>
#define u_int unsigned int
int main(void){
  struct ID{
    u_int id;
    u_int unit;
    u_int number;
  };
  u_int n,k,i,p,q,pro,count;
  struct ID *member;
  while(scanf("%d",&n)&&n!=0){
    member=(struct ID *)calloc(n,sizeof(struct ID));
    for(k=0;k<n;k++){
      scanf("%u %u %u",&((member+k)->id),&((member+k)->unit),&((member+k)->number));
    }
    count=0;
    for(k=0;k<n;k++){
      pro=((member+k)->unit)*((member+k)->number);
      if(pro>=1000000){
	printf("%u\n",(member+k)->id);
	count++;
      }
    }
    if(count==0) printf("NA\n");
    free(member);
  }
  return 0;
}
  
  
  
  