def answer():
    n = int(input())
    while n:
        a = [int(x) for x in input().split()]
        ans=0
        a1=min(a[1],int(a[2]/2))
        a[1]-=a1
        a2=min(a[0],int(a[1]/2))
        ans=3*(a1+a2)
        
        print(ans)
        n-=1
answer()