for _ in range(int(input())):
    a,b,c=map(int,input().split())
    total=0
    qb,qc=0,0
    if(b==0):
        print(0)
    elif(c==0):
        qb=min(a,b//2)
        total=qb*2+qb
        print(total)
    elif(a==0):
        qc=min(b,c//2)
        total=qc*2+qc
        print(total)
    else:
        qc=min(b,c//2)
        b-=qc
        qb=min(a,b//2)
        total=qc*2+qc+qb*2+qb
        print(total)
    
        
