import java.util.Scanner;
public class Main
{
    static void cal(int i,int j,int k,int count){
        if(j < 1 || j<2){
        System.out.print(count);
        return;}
        
        if(j>k && j>1){
            if(i>0){
            i=i-1;
            j=j-2;
            count+=3;
            }
            
        }
        if(k>=j && k>1){
            if(j>0){
            j=j-1;
            k=k-2;
            count+=3;
            }
        }
        cal(i,j,k,count);
        
    }
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int t=sc.nextInt();
	    while(t-->0){
	        int i=sc.nextInt();
	        int j=sc.nextInt();
	        int k=sc.nextInt();
		    cal(i,j,k,0);
	    }
		
	}
}