t= int(input())

for _ in range(t):
	s=0
	a,b,c=map(int,input().split())
	
	
	if c>=b*2:
		s+=3*b
		b=0
		c-=2*b
		
	
	x=c//2
	
	if x<=b and c>=2:
		s+=3*x
		b-=x
		c-=2*x
		
		
	if b>=a*2:
		s+=3*a
		a=0
		b-=2*a
		
	
	
	
	y=b//2
	
	
	if y<=a and b>=2:
		s+=3*y
		a-=y
		b-=2*y
		
		
		
	print(s)
	
