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