t=int(input())
for i in range(t):
    inp = list(map(int,input().split()))
    a=inp[0]
    b=inp[1]
    c=inp[2]
    ans=0
    k=min(c//2,b)
    ans+=3*k
    c-=k*2
    b-=k
    k=min(a,b//2)
    ans+=3*k
    print (ans)