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;
            sum += (c / 2) * 3;
            b -= c / 2;
            
            sum += (b / 2) * 3;

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