

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();

            while (b > 0) {
                if (b >= a && b <= c) {
                    while (b >= 1 && c >= 2) {
                        b--;
                        c -= 2;
                        s += 3;
                    }

                    while (a >= 1 && b >= 2) {
                        a--;
                        b -= 2;
                        s += 3;
                    }

                }else if(a != 0 && b != 1) {
                    while (a >= 1 && b >= 2) {
                        a--;
                        b -= 2;
                        s += 3;
                    }

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

            }

            System.out.println(s);
        }

    }
}
