t=int(input())
for i in range(0,t):
    an=0
    a,b,c=[ int(x) for x in input().split()]
    if(c>b):
        while(c>1 and b>0):
            c=c-2
            b=b-1
            an=an+3
        while(a>0 and b>1):
            a=a-1
            b=b-2
            an=an+3
    else:
        while(a>0 and b>1):
            a=a-1
            b=b-2
            an=an+3
        while(c>1 and b>0):
            c=c-2
            b=b-1
            an=an+3
    print(an)
        

        
