from math import ceil 

def ans(a,b,c):
	an = 0
	if b == 0:
		return 0
	if c//2 > b:
		return 3*b
	else:
		b -= c//2
		an += (c//2 ) *3
		return an+ans(0,a,b)



q = int(input())
for i in range(q):
	# n = int(input())
	a,b,c = map(int,input().split())
	print(ans(a,b,c))
