T = int(input())

for _ in range(T):
	(a, b, c) = (int(x) for x in input().split())

	result = 0

	while c >= 2 and b >= 1:
		result += 3
		c -= 2
		b -= 1

	while b >= 2 and a >= 1:
		result += 3
		b -= 2
		a -= 1

	print(result)