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