T = int(input())
for t in range(T):
    a,b,c=list(map(int,input().split()))
    sum=0
    if b==0:
        print(0)
        continue
    else:
        if b>=c//2:
            b=b-(c//2)
            sum+=3*(c//2)
            if a>=b//2:
                sum+=3*(b//2)
            else:
                sum+=3*a
        else:
            sum+=3*b
    print(sum)        
                
        
    
    

    