t = int(input())
for i in range(t):
    a,b,c=map(int, input().split())
    res=0
    possible = True
    while possible:
        if b>=1 and c>=2:
            c1=min(c//2,b)
            res+=c1*3
            b-=c1
            c-=c1*2
        elif b>=2 and a>=1:
            b1=min(b//2,a)
            res+=b1*3
            b-=b1*2
            a-=b1
        else:
            possible = False
    print(res)