import java.util.Scanner;
public class Main
{
    static void cal(int i,int j,int k){
        int count=0;
        while(j>0 && k>1){
            j--;
            k-=2;
            count++;
        }
        while(i>0 && j>1){
            i--;
            j-=2;
            count++;
        }
        System.out.print(count*3);
    }
	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);
	    }
		
	}
}