#include<stdio.h>

int main(){
  int n;
  while(scanf("%d",&n), n){
    int i, k, num[4000], flag=0;
    long unitPrice[4000], saleQuantity[4000], earning[4000]={0};
    for(i=0; i<n; i++){
      scanf("%d%ld%ld", &num[i], &unitPrice[i], &saleQuantity[i]);
      earning[i] = unitPrice[i]*saleQuantity[i];
      for(k=0; k<i; k++){
        if(num[i] == num[k]){
          earning[k] = earning[i] + earning[k];
          earning[i] = 0;
        }
      }
    }

    for(i=0; i<n; i++){
      if(earning[i]>=1000000){
	printf("%d\n", num[i]);
	flag+=1;
      }
    }
    if(flag == 0){
      printf("NA\n");
    }
    flag2 += 1;
  }
  return 0;
}