def program():
    a,b,c=input().split()
    a=int(a)
    b=int(b)
    c=int(c)
    li=[]

    for i in range(a+1):
        for j in range(c//2+1):
            if 2*i+j<=b:
                li.append(3*i+3*j)

    print(max(li))
    

t = int(input())

for x in range(t):
    program()