t=int(input())
while(t>0):
    ans=0
    a,b,c=map(int,input().split())
    if(c%2==0):
        f=min(c,2*b)
        ans+=f
        b-=(f//2)
    elif(c%2==1):
        f=min(c-1,2*b)
        ans+=f
        b-=(f//2)
    if(b%2==0):
        f=min(b,2*a)
        ans+=f
    elif(b%2==1):
        f=min(b-1,2*a)
        ans+=f
    # print(ans)
    ans=int(ans*1.5)
    print(ans)
    t-=1