import java.util.Scanner;
public class stones2
{
    public static void main(String args[])
    {
        Scanner s= new Scanner(System.in);
        int t= s.nextInt();
        int sum=0;
        for(int i=0; i<t; i++)
        {
            int a= s.nextInt();
            int b= s.nextInt();
            int c= s.nextInt();
            if(c%2!=0)
            c=c-1;
            int x, y;
            if(b==0 )
            sum=0;
            else if(b>=(c/2) && c>=2)
            {
                sum=sum+((3*c)/2);
                b=b-(c/2);
                if(b%2!=0)
                b--;
                if(a>=(b/2) && b>=2)
                {
                    sum=sum+((3*b)/2);
                    a=a-(b/2);
                }
                else if(a<(b/2) && b>=2) 
                {
                    sum=sum+(3*a);
                }
            }
            else if(b<(c/2) && c>=2)
            sum=sum+(3*b);
            System.out.println(sum);
        }
    }
}
