def answer():
    n = int(input())
    while n:
        a = [int(x) for x in input().split()]
        ans=0
        if a[1]>=int((a[2]/2)):
            ans+=a[2]+int(a[2]/2)-a[2]%2
            a[1]-=int(a[2]/2)
            if a[0]>=int(a[1]/2):
                ans+=a[1]+int(a[1]/2)-a[1]%2
            else:
                ans+=a[0]+a[0]*2
        else:
            ans+=a[1]+a[1]*2    
            if a[0]>=int(a[1]/2):
                ans+=a[1]+int(a[1]/2)-a[1]%2
            else:
                ans+=a[0]+a[0]*2
        print(ans)
        n-=1
answer()