T=int(input())
for epoch in range(T):
    a,b,c=map(int,input().split())
    sum=0
    for i in range(a+1):
        for j in range(c+1):
             if j%2==0 and (i*2+j//2)<=b:
                    sum=max(sum,i+j+i*2+j//2)
    print(sum)