t=int(input())
while t:
    t-=1
    a,b,c=map(int,input().split())
    ans=0
    uu=min(a,b//2)
    ans+=uu+2*uu
    b1=b-2*uu
    uv=min(b1,c//2)
    ans+=uv+2*uv
    ans1=0
    uu=min(b,c//2)
    ans1+=uu+2*uu
    b1=b-uu
    uv=min(a,b1//2)
    ans1+=uv+2*uv
    print(max(ans,ans1))
