T = int(input())
nums = [[int(i) for i in input().split()] for t in range(T)]

for t in range(T):
    a,b,c = nums[t]
    stonesTaken = 0
    while True:
        op1Valid = (a>=1) and (b>=2)
        op2Valid = (b>=1) and (c>=2)
        op1 = min(b//2,a)
        op2 = min(c//2,b)
        if op1Valid:
            if op2Valid:  
                if op1>op2:
                    b -= 2*op1
                    a -= op1
                else:
                    c -= 2*op2
                    b -= op2
                stonesTaken += 3*max(op1,op2)
            else:
                b -= 2*op1
                a -= op1
                stonesTaken += 3*op1
        elif op2Valid:
            c -= 2*op2
            b -= op2
            stonesTaken += 3*op2
        else:
            print(stonesTaken)
            break
