t=int(input())
l3=[]
for i in range(t):
	c=0
	a=0
	b=0
	l1=[int(num) for num in input().split()]

	if(l1[2]>=(2*l1[1])):
		l3.append(3*l1[1])
	else:
		if(l1[2]%2!=0):
			c=l1[2]-1
		else:
			c=l1[2]
		a=int(c/2)
		if(l1[0]>=l1[1]-a):
			b=int((l1[1]-a)/2)+2*(int((l1[1]-a)/2))
			l3.append(c+a+b)
		else:
			l3.append(c+a+3*l1[0])

for i in range(t):
	print(l3[i])




