T=int(input())
s=[]
for i in range(T):
    a,b,c=map(int,input().split())
    stone=0
    while(c!=0):
        if(c//2<=b):
            stone=2*(c//2)+c//2
            b-=c//2
            break
        else:
            c-=1

    while(b!=0):
        if(b//2<=a):
            stone=stone+2*(b//2)+b//2
            a-=b//2
            break
        else:
            b-=1

    s.append(stone)
for i in s:
    print(i)