
import java.util.*;
import java.io.*;
public class xyz{
static int max=0;
     static int X(int a,int b,int c,int sum) {
         if(sum>max) max=sum;
         if(b==0) {
             return sum;
         }
         else {
             if(a!=0&&b>=2) {
                 sum=X(a-1,b-2,c,sum+3);
             //    System.out.println(a+" "+b+" "+c+" "+sum);
                 sum=sum-3;
                 
             } 
             if(b>=1&&c>=2) {
                 sum=X(a,b-1,c-2,sum+3);
            //     System.out.println(a+" "+b+" "+c+" "+sum);
                 sum=sum-3;
             }
         }
      return sum;         
     }
    public static void main(String[] args) throws Exception{
        // TODO code application logic here
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   StringBuilder str=new StringBuilder();
  int test=Integer.parseInt(br.readLine());
  while((test--)!=0) {
  StringTokenizer st=new StringTokenizer(br.readLine());
   int a=Integer.parseInt(st.nextToken());
   int b=Integer.parseInt(st.nextToken());
   int c=Integer.parseInt(st.nextToken());
   // X(a,b,c,0);
   int sum=0;
 if(b%2==1) {
     if(a>=(b/2)){
      sum+=(b/2*3);
      b=1;
     }
     else {
         sum+=(a)*3;
         a=0;
         b=b-a*2;
     }
     if(b!=0) {
         if(2*b<=c) {
           sum  +=b*3;
         }
         else {
             sum+=(c/2)*3;
         }
     }
  }
 else {
     if(b<=(c/2)) {
           sum  +=b*3;
           b=0;
         }
         else {
             sum+=(c/2)*3;
             b=b-c/2;
         }
     if(b!=0) {
         
     }
     
 }
 System.out.println(sum);
  }
    
    }
    
}
