import java.util.Scanner;

public class Stones_1236A {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		for (int i = 0; i < n; i++) {
			int sum = 0;
			int a = input.nextInt();
			int b = input.nextInt();
			int c = input.nextInt();
			if (b >= 1 && c >= 2) {
				int x = c / 2;
				c %= 2;
				b -= x;
				sum += x + (x * 2);
			}
			if (a >= 1 && b >= 2) {
				int x = b / 2;
				b %= 2;
				a -= x;
				sum += x + (x * 2);
			}
			System.out.println(sum);
		}
		input.close();
	}
}