t=int(input())
while t>0:
	a,b,c=map(int,input().split())
	bh=b//2
	ch=c//2
	m1=min(a,bh)
	m2=min(b,ch)
	if m1>m2:
		m1=m1*3+min(b-m1*2,ch)*3
		print(m1)
	else:
		m2=m2*3+min(a,(b-m2)//2)*3
		print(m2)
	t=t-1