import java.util.Scanner;

public class A2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            int count=0;
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            if(b==0){
                System.out.println(0);
                continue;
            }
            if(b > 0 && c > 1){
                int x = c/2;
                b-=x;
                count += 3*x;
            }
            if(a > 0 && b > 1){
                int y = b/2;
                a-=y;
                count += 3*y;
            }
            System.out.println(count);
        }
    }
}
