t=int(input())
for ti in range(t):
    sto=0
    a,b,c=(int(i) for i in input().split(" "))
    if b>c//2:
        if c//2==0:
            if b<2:
                print(0)
            else:
                bb=b-c//2
                
                sto+=c//2*3
                sto+=min(a,bb//2)*3
                print(sto)
        else:
            bb=b-c//2
            
            sto+=c//2*3
            sto+=min(a,bb//2)*3
            print(sto)
    else:
        print(b*3)