t = int(input())

for i in range(t):
	a, b, c = list(map(int, input().split()))

	if b == 0:
		print(0)

	elif (b + c) >= (a + b) and b > 0 and c > 1:
		count = 2 * (c // 2) + c // 2
		b -= c // 2
		c -= 2 * (c // 2)

		if a > 0 and b > 1:
			count += 2 * (b // 2) + b // 2

		print(count)

	elif (a + b) > (b + c) and a > 0 and b > 1:
		count = 2 * (b // 2) + b // 2
		a -= b // 2
		b -= 2 * (b // 2)

		if b > 0 and c > 1:
			count += 2 * (c // 2) + c // 2

		print(count)

	else:
		print(0)
	