t = int(input())
for i in range(t):
	a, b, c = list(map(int, input().split()))
	x = 0
	if b == 0 or a == 0 and c == 0:
		print(0)
	else:
		x += min(b, c // 2)
		b -= x
		x += min(b // 2, a)
		print(x * 3)