# import sys
# sys.stdin = open("test.in","r")
# sys.stdout = open("test.out","w")
for i in range(int(input())):
	a,b,c=map(int,input().split())
	co=0
	e=c//2
	if b<=e:
		co+=3*b
	else:
		co+=3*e
		b=b-e
		f=b//2
		if a<=f:
			co+=3*a
		else:
			co+=3*f
	print(co)			