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