t=int(input())
for i in range(t):
	a,b,c=map(int,input().split())
	if(b==0):
		print(0)
	else:
		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
		print(count)