import java.io.*;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        for (int i = 0; i < t; i++) {

            int a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt();
            int res = 0;
            if (c > b) {
                int timesbc = Math.min(b, c / 2);
                res += 3 * timesbc;
                b -= timesbc;
                int timesab = Math.min(a, b / 2);
                res += 3 * timesab;
                System.out.println(res);
            } else {
                int timesab = Math.min(a, b / 2);
                res += 3 * timesab;
                b -= timesab;
                int timesbc = Math.min(b, c / 2);
                res += 3 * timesbc;
                System.out.println(res);
            }
        }
    }
}