import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        while(n--!=0){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int count = 0;
           sc.nextLine();
           
            while(a>0 && b>0 && c>1) {

                if (b >= 2) {
                    count++;
                    a--;
                    b -= 2;
                }
                if (b >= 1) {
                    count++;
                    b--;
                    c -= 2;
                }
            }
            System.out.println(count*3);
        }
    }
}
