for i in range(int(input())):
	a,b,c=map(int,input().split())
	x=0
	if c//2>0 and b>=1:
		for j in range(c//2):
			if b==0:
				break
			x+=3
			b-=1	
	if b//2>0 and a>=1:
		for j in range(b//2):
			if a==0:
				break
			x+=3
			a-=1	
	print(x)	