t=int(input())
for i in range(t):
    a,b,c=map(int,input().split())
    sum=0
    while(True):
        count=0
        if(c>=2 and b>0):
            x=min(c//2,b)
            sum+=3*x
            c=c-2*x
            b=b-x
            count=1
        elif(b>=2 and a>0):
            y=min(b//2,a)
            sum+=3*y
            b=b-2*y
            a=a-y
            count=1
        elif(count==0):
            break
    print(sum)