#stones.py

t = int(raw_input())
for n in range(t):
	line = [int(x) for x in raw_input().split(" ")]
	a = line[0]
	b = line[1]
	c = line[2]
	
	sol = 0
	while c >= 2 and b > 0:
		sol += 3
		c -= 2
		b -= 1
	
	while b >= 2 and a > 0:
		sol += 3
		b -= 2
		a -= 1
	
	print sol