t=int(input())
while(t!=0):
	a,b,c=input().split()
	a=int(a)
	b=int(b)
	c=int(c)
	m=a+b+c
	z=0

	while(b>0 and c>1):
		
		b=b-1
		c=c-2
		z+=3
		
	

	while(a>0 and b>1):
		a=a-1
		b=b-2
		z+=3
	print(z)
	t-=1


			

