import sys
t=int(sys.stdin.readline())

for i in range(t):

	[a,b,c]=[int(i) for i in sys.stdin.readline().split()]

	st2=min(b,c//2)
	b-=st2
	c-=st2*2

	st1=min(a,b//2)
	a-=st1
	b-=st1*2

	print(3*(st1+st2))