from math import ceil
n = int(input())
for i in range(n):
	a,b,c = map(int,input().split())
	if c%2 == 1:
		c = c - 1
	r = ceil(c//2)
	if c >= 2*b:
		print(3*b)
	elif b >= c//2 + 2*a:
		print(c+c//2+3*a)
	elif b >= c//2:
		# print("--")
		# print(c)
		print(c+c//2+3*(b-c//2)//2)
