def ii():return int(input())
def mi():return map(int,input().split())
t=int(input())
while(t):
    a,b,c=mi()
    k=c//2
    if(b<=k):
        print(3*b)
    else:
        ans=(3*k)
        b-=k
        b=b//2
        if(a>=b):
            ans+=(3*b)
        else:
            ans+=(3*a)
        print(ans)
    t-=1