from sys import stdin,stdout
I = lambda : map(int,stdin.readline().split())

n = input()
for _ in range(n):
	a,b,c = I()
	ans = 0
	p = 0
	if c>b:
		p = min(2*b,c - (c%2))
		# print p,"1"
		ans += p+(p/2)
		b -= p/2
		if b>=2:
			p = min(2*a,b- (b%2))
			# print p,"2"
			ans+=3*(p/2)
	else:
		p = min(2*a,b - (b%2))
		ans+=3*(p/2)
		b-=p
		if b>=1:
			p = min(c- (c%2),2*b)
			ans+=3*(p/2)
	print ans



