t=int(input())

for _ in range(t):
    pedras=0
    h1,h2,h3=list(map(int,input().split()))
    num_op2=min(h2, h3//2)

    #pedras+=3*num_op2

    h2-=num_op2

    num_op1=min(h1, h2//2)

    print((num_op2+num_op1)*3)





 	 	 	  						 	   	   		 				