k = int(input())
for _ in range(k):
	first_step = 0
	a, b, c = map(int, input().split())
	if ((c>1) & (b>0)):
		t = min(c//2, b)
		first_step = 3*t
		b = b - t
		z = min(b//2, a)
		first_step += z*3
		print(first_step)
	elif b == 0:
		print('0')
	elif c<=1:
		k = min(a, b//2)
		print(3*k)