t = int(input())
m=0
while(m<t):
    s = list(map(int,input().split()))
    a = s[0]
    b = s[1]
    c = s[2]
    k = 0
    if(b==0):
        print(0)
    else:
        while(c>1 and b>0):
            k=k+3
            c=c-2
            b=b-1
        while(b>1 and a>0):
            k=k+3
            b=b-2
            a=a-1
            
        print(k)
        
    m=m+1