import java.util.Scanner;

public class A_Stones {
    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();

        for (int i = 1; i <= t; i++) {
            int s = 0;

            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();

            if (b >= 1 && c >= 2){
                b -= c/2;
                s += c/2;
            }

            if (a >= 1 && b >= 2){
                a -= b/2;
                s += b/2;
            }

            System.out.println(s * 3);
        }
    }
}
