# import sys
# file = open('test')
# sys.stdin = file
def ii():
	a = int(input())
	return a
def ai():
	a = list(map(int, input().split()))
	return a
def mi():
	a = map(int, input().split())
	return a


for _ in range(ii()):
	a,b,c = mi()
	ans = 0
	if b>=(c//2):
		ans += (c//2+(c//2)*2)
		b -= c//2
		# print("B",b)
	elif b<(c//2):
		ans += (b+(b)*2)
		print(ans)
		continue
	if a>=(b//2) and b!=0:
		ans += (b//2+(b//2)*2)
	elif a<(b//2):
		ans += a+(a)*2
	print(ans)