t=int(input())
s=[]
for jnnj in range(0,t):
    x=input()
    xx=x.split( )
    a=int(xx[0])
    b=int(xx[1])
    c=int(xx[2])
    g=0
    if b==0:
        s.append(0)
    else:
        while b>=1 and c>=2:
            g+=3
            b-=1
            c-=2
        while b>=2 and a>=1:
            g+=3
            a-=1
            b-=2
        s.append(g)
for i in s:
    print(i)
