import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while(t-- > 0) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int count = (int) Math.min(c/2, b) * 2;
            int sum = count;
            b -= Math.min(c/2, b);
            sum += Math.min(c/2, b);
            sum += (int) Math.min(b/2, a) * 3;
            System.out.println(sum);
        }
    }
}
