for _ in range(int(input())):
	x,y,z=map(int,input().split())
	p=0
	if y==0 or x==0 and z==0:
		print('0')
	else:
		if z//2<=y:
			p=(z//2)*2+(z//2)+p
			y=y-(z//2)
			z=0
		elif z//2>y:
			p=p+y+y*2
			print(p)
			continue
		if y//2<=x:
			p=p+(y//2)*2 +(y//2)
			x=x-(y//2)
			y==0
		elif y//2>x:
			p=p+x+x*2
			print(p)
			continue
		print(p)