# import sys
# sys.stdin=open("input1.in","r")
# sys.stdout=open("OUTPUT3.out","w")
for i in range(int(input())):
    a,b,c=map(int,input().split())
    ans=0
    if c>=b*2:
        ans=3*b
        print(ans)
    elif c<b*2:
        b=b-c//2
        ans=(c//2)*3
        if b>=a*2:
            ans+=3*a
            print(ans)
        elif b<a*2:
            ans+=(b//2)*3
            print(ans)

