for i in range(int(input())):
    count=0
    a,b,c=map(int,input().split())
    if((c>1 and b>0) and (c//2)>b):
        #print(count,1)
        c=c-(2*b)
        count=count+(3*b)
        b=0
    elif((c>1 and b>0) and (c//2)<b):
        #print(count,2,b)
        count=count+((c//2)*3)
        b=b-(c//2)
        c=0
        #print(b)
    if((b>1 and a>0) and (b//2)>a):
        b=b-(2*a)
        #print(count,3)
        count=count+(3*a)
    elif((b>1 and a>0) and (b//2)<a):
        #print(count,4,b)
        count=count+((b//2)*3)
        b=0
    print(count)
        
        
        
