for _ in range(int(input())):
    a,b,c=map(int,input().split())
    s=(c//2)*2
    s1=s
    if(b>=(s//2)):
        s1=s1+(s//2)
        b=b-(s//2)
        b=(b//2)*2
        if(a>=(b//2)):
            s1=s1+(b)+(b//2)
        else:
            s1=s1+a*2+a
    else:
        s1=b+b*2
        b=(b//2)
        if(a>=b):
            s2=b+b*2
            s1=max(s1,s2)
    print(s1)
        
    
        
        