for m in range(int(input())):
	abc = list(map(int, input().split()))
	stones = 0
	if abc[1] >= 1:
		if abc[2] >= 2 and abc[1] >= 1:
			stones += 3 * (min(abc[2] // 2, abc[1]))
			abc[2] -= ((min(abc[2] // 2, abc[1])) * 2)
			abc[1] -= (stones // 3)
		if abc[1] >= 2 and abc[0] >= 1:
			stones += 3 * (min(abc[1] // 2, abc[0]))
	print(stones)