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

public class GFG {
    
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader (System.in));
        int t=Integer.parseInt(br.readLine());
        while(t-->0)
        {
        StringTokenizer tk=new StringTokenizer(br.readLine());
        int a=Integer.parseInt(tk.nextToken());
        int b=Integer.parseInt(tk.nextToken());
        int c=Integer.parseInt(tk.nextToken());
        int ans=0,i=0,j=b;
        if(b==0)
        System.out.println(0);
        else
        {
            i=c/2;
            j=j-i;
            if(j>=0)
            {
                ans=i*3;
                b=j;
            }
            else
            {
                ans=b*3;
            }
            if(b>=2)
            {
                i=b/2;
                if(a-i>=0)
                ans+=i*3;
                else
                ans+=a*3;
            }
            
        System.out.println(ans);    
        }
        
            
        }
        	}
}