import java.util.*;
public class Stone {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int count =0;
        for (int i = 1; i <= t; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            if(a==0||b==0||c==0) System.out.println(0);
            if(a==1||b==1||c==1)System.out.println(0);
            else {
                while (b != 0 && c != 0 && a != 0) {
                    if (a >= 1 && b >= 2) {
                        count += 1;
                        a -= 1;
                        count += 2;
                        b -= 2;
                    }
                    if (b >= 1 && c >= 2) {
                        count += 1;
                        b -= 1;
                        count += 2;
                        c -= 2;
                    }
                }
                System.out.println(count);
                count =0;
            }


        }

    }
}
