# your code goes here
for _ in range(int(input())):
	a,b,c=[int(i) for i in input().split()]
	temp=c//2
	for i in range(temp,-1,-1):
		if(b>=i):
			break
	count=i+2*i
	b-=i
	temp=b//2
	for i in range(temp,-1,-1):
		if(a>=i):
			break
	count+=i+2*i
	print(count)