t=int(input())
for i in range(t):
	a,b,c=map(int,input().split())
	if((a>=1 and b>=1) and c>=2):
		if(c>=a):
			count=0
			for j in range(100):	
				if(c>=2 and b>=1):
					c=c-2
					b=b-1
					count=count+3
				elif(b>=2 and a>=1):
					b=b-2
					a=a-1
					count=count+3
		elif(c<a):
			count=0
			for j in range(100):	
				if(b>=2 and a>=1):
					b=b-2
					a=a-1
					count=count+3
				elif(c>=2 and b>=1):
					c=c-2
					b=b-1
					count=count+3
		print(count)
	else:
		print(0)