q=int(input())
for i in range(q):
    ans=0
    w,e,r=map(int,input().split())
    while r>1 and e>0:
        ans+=3
        r-=2
        e-=1
    while e>1 and w>0:
        ans+=3
        e-=2
        w-=1
    print(ans)