for _ in range(int(input())):
    A,B,C = map(int,input().split())
    val = C//2
    tot=0
    if(B>val):
        tot+=val
        tot+=(val*2)
        B-=val
    else:
        tot+=B
        tot+=(B*2)
        B = 0
    var = B//2
    if(A>var):
        tot+=var
        tot+=(var*2)
        A-=var
    else:
        tot+=A
        tot+=(A*2)
        A=0
    print(tot)
