import java.util.Scanner;

public class _0225Stones {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int cases =sc.nextInt();
		while(cases>0) {
			int a =sc.nextInt();
			int b=sc.nextInt();
			int c=sc.nextInt();
			int sum=a+b+c;
			int res1=0;
			int res2=0;
			if(b<=c&&b>=1&&c>=2) {
		//		System.out.println("upper");
				 res1=Math.min(b, c/2);
				b-=res1;
				c-=2*res1;
		//		System.out.println(a+" "+b+" "+c);
				if(b>=2&&a>=1) {
			//	System.out.println("upper");

				 res2=Math.min(a, b/2);
				a-=res2;
				b-=2*res2;
		//		System.out.println(a+" "+b+" "+c);

			}
			}
			else if(a>=1&&b>=2){
			//	System.out.println("lower");

				 res2=Math.min(a, b/2);
				a-=res2;
				b-=2*res2;
			}
					
			if(b>=1&&c>=2) {
				 res1=Math.min(b, c/2);
				b-=res1;
				c-=2*res1;
				}
			
		System.out.println(sum+-a-b-c);
		cases--;
		}
	}

}
