import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while (t-- > 0) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
            if (b == 0) {
                System.out.println(0);
                continue;
            }
            
            int sum = 0;
            
            while (b > 0) {
                if (c > 1 && b <= c) {
                    sum += 3;
                    b--; c -= 2;
                } else if (a > 0) {
                    sum += 3;
                    a--; b -= 2;
                } else {
                    break;
                }
            }

            System.out.println(sum);
        }
    }
}
