import sys
inputfn = sys.stdin.readline

t = int(inputfn())
for i in range(t):
	total = 0
	piles = inputfn().split(" ")
	piles[0] = int(piles[0])
	piles[1] = int(piles[1])
	piles[2] = int(piles[2])
	if 2 * piles[1] <= piles[2]:
		print(3 * piles[1])
		continue
	total += piles[2] // 2
	piles[1] -= piles[2] // 2
	total += min(piles[0], piles[1] // 2)
	print(3 * total)

