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

    