for i in range(int(input())):
    a,b,c=map(int,input().split())
    a2=a//2;b2=b//2
    n=0
    if(b>=1):
        if(b>c//2):
            n+=3*(c//2)
            b-=n//3
        else:
            n+=3*b
            b=0
    #print(a,b,c,n)
    if(a>=1):
        if(a>b//2):
            n+=3*(b//2)
            a-=n//3
        else:
            n+=3*a
            a=0
    print(n)
