def cout_stone(stone):
    stone[0]=int(stone[0])
    stone[1]=int(stone[1])
    stone[2]=int(stone[2])

    sum=0
    if stone[1]>=stone[2]//2:
        sum=stone[2]//2*3
        stone[1]-=stone[2]//2
        if stone[0]>=stone[1]//2:
            sum+=stone[1]//2*3
        else:
            sum+=stone[0]*3
    else:
        sum+=stone[1]*3
    print(sum)



n= int(input())
i=0
stone=[]
while i<n:
    s=(input().split(" "))
    stone.append(s)
    i+=1
for i in range(n):
    cout_stone(stone[i])