t = int(input())
s =0
for i in range(0, t):
    a,b,c = map(int, input().split())
    while True:
        if  b>0 and c>1:
             
                s+= 3
                b=b-1
                c=c-2
                
        elif a>0 and b>1:          
                s+=3
                a = a-1
                b=b-2
                
        else:
            break
    print(s)
    s=0
            