n=int(input())
while(n):
    z=0
    a,b,c=map(int, input().split())
    while(a>=1 and b>=2):
        a-=1
        b-=2
        z+=3
        if b>=1 and c>=2:
            b-=1
            c-=2
            z+=3 
        else:
            z+=0
    while(b>=1 and c>=2):
        b-=1
        c-=2
        z+=3 
        if a>=1 and b>=2:
            a-=1
            b-=2
            z+=3
        else:
            z+=0
    print(z)
    n-=1

    