tes=int(input())
for i in range(0,tes):
    a,b,c=input().split()
    a=int(a)
    b=int(b)
    c=int(c)
    ans=0
    if((c//2)>b):
        ans=ans+b+(2*b)
    else:
        ans=ans+((c//2)*2)+(c//2)
        b=b-(c//2)
        if(b//2<a):
            ans=ans+(b//2)*3
        else:
            ans=ans+(2*a)+a
    print(ans)