t= int(input())


for i in range(t):
    count = 0
    a,b,c = list(map(int,input().split(' ')))

    p = c//2      

    if b >= p:
        count+= 3*p
        b-=p
    else:
        count+= 3*b
        b = 0

    if b != 0:
        if a >= b//2:
            count+= 3*(b//2)

        else:
            count+= 3*a
            
    print(count)        
        
