t=int(input())
while t:
    t-=1
    a,b,c=map(int,input().split())
    ans=0
    while b>0 and a>0 and c>0:
        if b>=c and b>=2:
            b-=2
            a-=1
            ans+=3
        elif c>b and c>=2:
            c-=2
            b-=1
            ans+=3
        if c<=1 and b<=1:
            break
        #print(a,b,c)
    print(ans)
