t=int(input())
for _ in range(t):
    a,b,c=map(int,input().split())
    ans=0
    if b>=c//2:
        b=b-c//2
        ans+=2*(c//2)+c//2
        if a>=b//2:
            ans+=2*(b//2)+b//2
        else:
            ans+=a+2*a
        print(ans)
    else:
        ans+=b+2*b
        print(ans)