while(<>) {                            
    chomp;                            
    @line = split;                    
    if ($line[0]=~/^[0-9][0-9]?/) {    
	$val=$line[0];                 
	$a=1;
      FRASE:for ($val==$a; $a++;) {    
	  $r=\@line;                  
	  if ($val==1) {
	      %frase = ();
	      %prep = ();
	      %comp = ();
	      %verbs = ();
	  }
	  %frase = ($r[0] => $r);  
	PREP:if ($frase{$r[0]}[7]=~/^prep$/){   
	    if ($frase{$r[0]}[2]=~/^[A-Za-z]+[^@#\/%\=\$\^\*][-]?/){ 
		$lemmaprep=\$frase{$r[0]}[2];
		$cod=$frase{$r[0]}[0];        
		$head=$frase{$r[0]}[6];            
		$head=int $head;
		$cod=int $cod;
		%prep = ($cod=> [$head,$$lemmaprep,$cod]);
	    }
	} 
	COMP:if($frase{$r[0]}[7]=~/^comp$/){   
	    if ($frase{$r[0]}[2]=~/^[A-Za-z]+[^@#\/%\=\$\^\*][-]?/){ 
		$id=$frase{$r[0]}[0]; 
		$rif=$frase{$r[0]}[6];
		$lemmacomp=\$frase{$r[0]}[2];         
		%comp = ($id=> [$id,$$lemmacomp,$rif]);
	    } 
	} 
	VERB:if($frase{$r[0]}[3]=~/^V$/){   
	      if ($frase{$r[0]}[2]=~/^[A-Za-z]+[^@#\/%\=\$\^\*][-]?/){ 
		  $verb=$frase{$r[0]}[0]; 
		  $lemmaverb=\$frase{$r[0]}[2];         
		  %verbs = ($verb=> [$verb,$$lemmaverb]);
	      }
	  }  
	SINT_PREP:if($comp{$id}[0]==$prep{$cod}[0]){
		$head_comp=$comp{$id}[2];
		$sint_prep="$comp{$id}[1]_$prep{$cod}[1]";
		%sint=($head_comp=>[$head_comp,$sint_prep]);
		delete $comp{$id};
		delete $prep{$cod};
	}
	STAMPA:if($sint{$head_comp}[0]==$verbs{$verb}[0]){
		print "$verbs{$verb}[1]\t$sint{$head_comp}[1]\n";
		delete $verbs{$verb};
	    }
	  %frase = ();
	  last FRASE;                    
      } 
    }
}
