t=int(input())
for  _ in range(t):
    a,b,c = map(int,input().split())
    val=c//2
    ans=0
    if b>=val:
        b-=val
        c-=val*2
        ans+=val*2+val
    else:
        ans+=3*b
        c-=2*b
        b=0

    if b!=0:
        val1=b//2

        if a>=val1:
            a-=val1
            b-=val1*2
            ans+=val1*3
        else:
            ans+=3*a
            b-=2*a
            a=0
    print(ans)
