
import java.util.Arrays;
import java.util.Scanner;
public class codeForces {
	public static void main(String[] args) {
		Scanner inp = new Scanner(System.in);
		int t=inp.nextInt();
		while(t-->0) {
		int arr[]=new int [3],ans=0;
		for(int i=0;i<arr.length;++i) {
			arr[i]=inp.nextInt();
		}
		if(arr[2]!=0&&arr[1]!=0) {
		ans=3*(arr[2]/2);
		arr[1]-=arr[2]/2;
//		System.out.println(ans);
		}
		if(arr[1]!=0&&arr[0]!=0) {
			ans+=3*(arr[1]/2);
//			System.out.println(ans);
			
		}
	System.out.println(ans);
	}
	}

}