
t = int(input())

for i in range(t):
	a, b, c = [int(x) for x in input().split()]
	count = 0
	if b >= a:
		cs = min(b, c//2)
		count += 3 * cs
		b -= cs
		bs = min(a, b//2)
		count += 3 * bs
	else:
		bs = min(a, b//2)
		count += 3 * bs
		b -= bs
		cs = min(b, c//2)
		count += 3 * cs
	print(count)