def max_stones(a, b, c):
	total = 0
	if c//2 <= b:
		total += c//2*3
		b -= c//2
	else: return b*3
	
	if b//2 <= a:
		total += b//2*3
	else: total += a*3
	
	return total

for _ in range(int(input())):
	a,b,c = map(int, input().split())
	print(max_stones(a,b,c))