import java.util.Scanner;

public class AStones {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int runs = sc.nextInt();
		while(runs-->0) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int out = 0;
			if(b<=c) {
				while(b>=1&&c>=2) {
					b--;
					c-=2;
					out+=3;
				}
				while(a>=1&&b>=2) {
					a--;
					b-=2;
					out+=3;
				}
				System.out.println(out);
			}else {
				while(a>=1&&b>=2) {
					a--;
					b-=2;
					out+=3;
				}
				while(b>=1&&c>=2) {
					b--;
					c-=2;
					out+=3;
				}
				System.out.println(out);
			}
		}

	}

}
