t=int(input())
for tt in range(t):
	a,b,c=map(int,input().split())
	xx=min(a,b//2)
	yy=min(b-2*xx,c//2)
	ans1=3*(yy+xx)
	xx1=min(b,c//2)
	yy1=min(a,(b-xx1)//2)
	ans2=3*(xx1+yy1)
	print(max(ans1,ans2))