n=int(input())
for i in range(n):
    sum=0
    x=list(map(int,input().split()))
    while (x[0]>0 or x[1]>0):
        if x[2]>=2 and x[1]>=1:
            sum+=3
            x[1]-=1
            x[2]-=2
        elif x[1]>1 and x[0]>0:
            sum+=3
            x[0]-=1
            x[1]-=2
        else:
            break
    print(sum)