def mx(a,b):
    if(a>b):
        return a
    else:
        return b
t=int(input())
if(t>=1 and t<=100):
    for _ in range(t):
        l=list(map(int,input().split()))
        if min(l)>=0 and max(l)<=100:
            count=0
            while (l[0]>0 and l[1]>1) or (l[1]>0 and l[2]>1):
                if(l[2]==mx(l[1],l[2])):
                    l[2]-=2
                    l[1]-=1
                    count+=3
                else:
                    l[1]-=2
                    l[0]-=2
                    count+=3
            print(count)
