t=int(input())
a=[]
b=[]
c=[]

for i in range(t):
    values=input().split()
    abc=[int(x) for x in values]
    a.append(abc[0])
    b.append(abc[1])
    c.append(abc[2])
    

    
    
def stones(t,a,b,c):
    stones=0
    while t>0:
        if c>=2 and b>=1:
            c-=2
            b-=1
            stones+=3
        elif b>=2 and a>=1:
            b-=2
            a-=1
            stones+=3
        t-=1
    return stones

for i in range(t):
    print(stones(t,a[i],b[i],c[i]))

