import java.util.Scanner;

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

    }

