import java.util.*;
public class main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int q=sc.nextInt();
		for(int w=0;w<q;w++){
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int x=0,y=0,z=0;
		for(int i=c;i>1;i-=2){
			c=c-2;
			y=++y;
			if(y>b) break;
		}
		for(int j=(b-y);j>1;j-=2){
			if((b-y)<=1) break;
			z=++z;
			if(a-z<=0) break;
		}
		if(b<=0){
			System.out.println("0");
		}else{
			System.out.println(3*y+3*z);
		}
		}
	}
}
	  	 	 	    		  	 					 	 		