t=int(input())
for _ in range(t):
    x=0
    a,b,c=map(int,input().split())
    if(b>=c//2):
        x+=(c//2)*3
        b-=c//2
        if(a>=b//2):
            x+=(b//2)*3
        else:
            x+=3*a
    else:
        x+=3*b
    print(x)