
t = int(input())
for _ in range(t):
	n1, n2, n3 = map(int, input().split())
	co = 0
	while n3 >= 2 and n2 >= 1:
		co += 3
		n3 -= 2
		n2 -= 1

	while n2 >= 2 and n1 >= 1:
		co += 3
		n2 -= 2
		n1 -= 1
	print(co)
