t = int(input())
for i in range(t):
	inp = input()
	inp_arr = inp.split(" ")
	a = int(inp_arr[0])
	b = int(inp_arr[1])
	c = int(inp_arr[2])
	set1 = set()
	
	for n in range(0,a+1):
		for m in range(0, c//2+1):
			if 2*n+m<=b:
				set1.add(3*(m+n))

	print(max(set1))
