import java.util.*;
import java.io.*;

public  class main{
	
	public static void main(String[] args) throws Exception {
		   
		  //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          	Scanner sc = new Scanner(System.in);
          	int t = sc.nextInt();
          int a=0,b=0,c=0;
          int d=0;
          for(int i=0;i<t;i++){
         // a=Integer.parseInt(br.readLine());
          //b=Integer.parseInt(br.readLine());
          //c=Integer.parseInt(br.readLine());
          a=sc.nextInt();  
          b=sc.nextInt();  
          c=sc.nextInt(); 
          d = res(a,b,c);
           System.out.println(d);
          }
         
         
          
		  
		
		}

	static int res(int a, int b, int c) {
		 int k =0;
 		 int l=0;
          
          if(c>b && c>a) {
        	  while(b>=1 && c>=2) {
    			  b=b-1;
    			  k=k+1;
    			 
    			  c=c-2;
    			  k=k+2;
    		
    		  }

    		  while(a>=1 && b>=2) {
    			  a=a-1;
    			 l=l+1;
    			  b=b-2;
    			 
    			  l=l+2;
    			
    		  }
    		
    		 
          }else if(b>a && b>c)  {
		
		  while(a>=1 && b>=2) {
			  a=a-1;
			 l=l+1;
			  b=b-2;
			 
			  l=l+2;
			
		  }
		  while(b>=1 && c>=2) {
			  b=b-1;
			  k=k+1;
			 
			  c=c-2;
			  k=k+2;

		  }
		 
          }
          else if(a>b) {
        	  while(a>=1 && b>=2) {
    			  a=a-1;
    			 l=l+1;
    			  b=b-2;
    			 
    			  l=l+2;
    			
    		  }
    		  while(b>=1 && c>=2) {
    			  b=b-1;
    			  k=k+1;
    			 
    			  c=c-2;
    			  k=k+2;
    			
    		  }
          }
		return k+l;
	}
 

		
}
 
