import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int test = sc.nextInt();
		for(int i=0;i<test;i++) {
			int heap1 = sc.nextInt();
			int heap2 = sc.nextInt();
			int heap3 = sc.nextInt();
			int max =0;
			while(heap1>0&&heap2>1||heap2>0&&heap3>1) {
				if(heap1>0&&heap2>1) {
					heap1=heap1-1;
					heap2=heap2-2;
					max=max+3;
					if(heap2>0&&heap3>1) {
						heap2=heap2-1;
						heap3=heap3-2;
						max=max+3;
				    }
				} else if(heap2>0&&heap3>1) {
							heap2=heap2-1;
							heap3=heap3-2;
							max=max+3;
				}
			}
			System.out.println(max);
		}
	}
}


	 		  	 						 			    		 	 		