def sol(a,b,c,s):
    if a>0 and b>1:
        sol(a-1,b-2,c,s+3)
    if b>0 and c>1:
        sol(a,b-1,c-2,s+3)
    ans[0]=max(ans[0],s)
    return ans[0]
ans=[0]
#print sol(7,3,10,0)

for _ in range(input()):
    a,b,c=map(int,raw_input().split())
    s=0
    ans=0
    for i in range(a):
        x,y,z=a,b,c
        s+=3
        a=a-i
        b=b-(i*2)
        t=min(z/2,y)
        s=t*3
        y-=t
        z-=2*t
        t=min(y/2,x)
        s+=t*3
        x-=t
        y-=2*t
        ans=max(s,ans)
    print ans
            
