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