for _ in range(int(input())):
    m,n,l=map(int,input().split())
    i=m
    j=n
    k=l
    c=0
    t=0
    while m>=1 and n>=2:
        m=m-1
        n=n-2
        c+=3
    while n>=1 and l>=2:
        n=n-1
        l=l-2
        c+=3
    while j>=1 and k>=2:
        j=j-1
        k=k-2
        t+=3
    while i>=1 and j>=2:
        i=i-1
        j=j-2
        t+=3
    print(max(t,c))
    
    