t = int(input())
for _ in range(t):
	a,b,c = map(int,input().split())
	A = a
	B = b
	C = c
	ans = 0
	# case 1
	B = b//2
	ans = min(A,B) * 3
	B = b - min(A,B)*2
	C = c//2
	ans = ans + min(B,C)*3
	A = a
	B = b
	C = c
	ans1 = 0
	#case 2 
	C = c//2
	ans1 = min(B,C)*3
	B = b - min(B,C)
	B = B//2
	ans1 = ans1 + min(A,B)*3
	print(max(ans,ans1))  
