n = int(input())
for i in range(n):
    sum = 0
    l = list(map(int,input().split(" ")))
    if(l[1]==0):
        sum += 0
    else:
        if(l[2]>=2*l[1]):
            sum += 3*l[1]
        else:
            if(l[2]%2==0):
                sum+=l[2]
                sum+=int(l[2]/2)
                l[1]-=int(l[2]/2)
            else:
                sum+=(l[2]-1)
                sum+=int((l[2]-1)/2)
                l[1]-=int((l[2]-1)/2)
            if(l[0]==0):
                sum+=0 
            elif(l[1]>=2*l[0]):
                sum+=3*l[0]
            else:
                if(l[1]%2==0):
                    sum+=l[1]
                    sum+=int(l[1]/2)
                else:
                    sum+=(l[1]-1)
                    sum+=(l[1]-1/2)
    print(sum)
                
            
            