n = int(input())

for i in range(n):
	a, b, c = [int(x) for x in input().split()]
	
	q1 = 0
	q2 = 0

	q1 = min(a,int(b/2))*3
	a2 = a - min(a,int(b/2))
	b2 = b - 2*min(a,int(b/2))
	q1= q1 + min(b2,int(c/2))*3

	q2 = min(b,int(c/2))*3
	b3 = b - min(b,int(c/2))
	c3 = c - 2*min(b,int(c/2))
	q2 = q2 + min(a,int(b3/2))*3

	if q1 > q2:
		print(q1)
	else:
	    print(q2)
   		  	 	 	 	  			   	    	  	