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

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s[];
		int t = Integer.parseInt(br.readLine());
		int a, b, c, x ,y;
		for (int i = 0; i < t; i++) {
			s = br.readLine().split(" ");
			a = Integer.parseInt(s[0]);
			b = Integer.parseInt(s[1]);
			c = Integer.parseInt(s[2]);
			
			if(a + c/2 <= b) {
				y = c/2;
				System.out.println(3*(a + y));
			}else if(b - c/2 >= 0) {
				x = (b - c/2);
				x /= 2;
				y = c/2;
				System.out.println(3 * (x + y));
				
			}else {
				System.out.println(3*b);
			}
		}

	}
}