n=int(input())
for i in range(n):
    ans=0
    a,b,c=input().split()
    a=int(a)
    b=int(b)
    c=int(c)//2
    if b>c:
        b-=c
        ans+=c
    else:
        ans+=b
        b=0
    b=b//2
    if a>b:
        a-=b
        ans+=b
    else:
        ans+=a
        a=0
    print(ans*3)