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