t = int(input())

for a in range(t):
	a,b,c = list(map(int, input().split()))
	output = 0
	while c >=2 and b >=1:
		c-=2
		b-=1
		output+=3
	while a >=1 and b >=2:
		a-=1
		b-=2
		output+=3
	print(output)