n=int(input())
for i in range(n):
	a,b,c=map(int,input().split())
	t=0
	if b == 0:
		print(0)
	else:
		if c >=2:
			c=min((c//2),b)
			t+=(3*c)
			b-=c
		if a >= 1 and b > 1:
			b=min((b//2),a)
			t+=(3*b)
		print(t)
