def f():
    a,b,c=map(int,input().split(" "))
    maxi=0
    for x in range(0,a+1):
        for y in range(0,c//2+1):
            if (b-2*x-y>=0):
                maxi=max(maxi,3*x+3*y)
                    
    print (maxi)
for i in range(int(input())):
    f()
            
        

