t=int(input())
for i in range(t):
    a,b,c=map(int,input().split())

    ans=0
    while(1):
        if b>=1 and c>=2:
            b-=1
            c-=2
            ans+=3
        elif a>=1 and b>=2:
            a-=1
            b-=2
            ans+=3
        else:
            break
    print(ans)