import java.util.Scanner;

public class CF1236A {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		for (int i = 0; i < n; i++) {
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();
			int stones = 0;
			if(c>b) {
				int num = c/2;
				int taken = num;
				if(num>b) {
					taken=b;
				}
				stones+=(taken*2)+taken;
				b=b-taken;
				int num1 = b/2;
				taken = num1;
				if(num1>a) {
					taken=a;
				}
				stones+=(taken*2)+taken;
			}else {
				int num = b/2;
				int taken = num;
				if(num>a) {
					taken=a;
				}
				stones+=(taken*2)+taken;
				b=b-(taken*2);
				int num1 = c/2;
				taken = num1;
				if(num1>b) {
					taken=b;
				}
				stones+=(taken*2)+taken;
			}
			System.out.println(stones);
		}

	}

}
