t=int(input())
while(t>0):
    a,b,c=map(int,input().split())
    if b==0:
        print(0)
    else:
        s=0
        x=c//2
        s+=3*x
        if b>x:
            b=b-x
            y=b//2
            a=a-y
            s+=3*y
        print(s)
    t-=1
    