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

public class Codeforces
{
	public static void main (String[] args) throws java.lang.Exception
	{
        Scanner in =new Scanner(System.in);
        int t=0;
        if(in.hasNext())
            t=in.nextInt();
        while(t-->0)
        {
            int arr[]=new int[3];
            for(int i=0;i<3;i++)
                arr[i]=in.nextInt();

            int sum=0;
            if(arr[1]>arr[2])
            {
                while(arr[0]-1>=0&&arr[1]-2>=0)
                {
                    arr[0]-=1;
                    arr[1]-=2;
                    sum+=3;
                }
                while(arr[1]-1>=0&&arr[2]-2>=0)
                {
                    arr[1]-=1;
                    arr[2]-=2;
                    sum+=3;
                }
            }
            else
            {
                while(arr[1]-1>=0&&arr[2]-2>=0)
                {
                    arr[1]-=1;
                    arr[2]-=2;
                    sum+=3;
                }
                while(arr[0]-1>=0&&arr[1]-2>=0)
                {
                    arr[0]-=1;
                    arr[1]-=2;
                    sum+=3;
                }
            }
            System.out.println(sum);
        }
	}
}
