t=int(input())
def fun(a,b,c):
    
    s=0
    if c==0:
        print(min(a,int(b/2)))
    elif a==0:
        print(min(b,int(c/2)))
    elif b==0:
        print(0)
    else:
        s=0
        k=min(b,int(c/2))
        b-=k
        c-=2*k
        s+=3*k
        if b==0 or b==1:
            print(s)
        else:
            s+=3*min(a,int(b/2))
            print(s)
while t:
    t-=1
    a,b,c=map(int,input().split())
    fun(a,b,c)
