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